Skip to content

Commit

Permalink
new |testfmtspec|
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidMorano committed May 25, 2024
1 parent 9029c2f commit fb4797e
Show file tree
Hide file tree
Showing 2 changed files with 122 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/testmisc/mainstring.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,12 @@ extern "C" char *strwcpy(char *,cchar *,int) ;
/* local variables */


/* exported subroutines */
/* exported variables */


/* exported subroutines */

int main(int argc,const char **argv,const char **envv)
{
int main(int argc,const char **argv,const char **envv) {
string s = "hello world!" ;
string w ;
int i ;
Expand Down Expand Up @@ -103,7 +104,7 @@ int main(int argc,const char **argv,const char **envv)
delete [] bp ;
} else {
rs = SR_NOMEM ;
} /* end if (m-a) */
} /* end if (m-a-f) */
}


Expand Down
117 changes: 117 additions & 0 deletions src/testmisc/testfmtspec.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
/* testfmtspec SUPPORT */
/* lang=C++98 */

/* test the FMTSPEC object */
/* version %I% last-modified %G% */


/* revision history:
= 1998-12-01, David A­D­ Morano
This subroutine was written for Rightcore Network Services.
*/

/* Copyright © 1998 David A­D­ Morano. All rights reserved. */

/*******************************************************************************
This program shows (prints out) object addresess.
*******************************************************************************/

#include <envstandards.h> /* MUST be ordered first to configure */
#include <sys/types.h>
#include <climits>
#include <cstddef> /* |nullptr_t| */
#include <cstdarg>
#include <cstdio>
#include <string> /* |strlen(3c)| */
#include <new>
#include <initializer_list>
#include <utility>
#include <functional>
#include <algorithm>
#include <string>
#include <iostream>
#include <usystem.h>
#include <localmisc.h>

#include "fmtspec.hh"


/* local defines */


/* imported namespaces */

using namespace std ; /* yes, we want punishment! */


/* external subroutines */


/* local structures */


/* forward references */

static int sub(int,mainv,...) ;


/* local variables */

constexpr cpcchar fmts[] = {
"4.3dxxx",
"08xxxx",
"10dxxx",
"10uxxx",
"10oxxx",
"10hljhljdx",
"12lldxx"
} ;


/* exported variables */


/* exported subroutines */

int main(int argc,mainv argv,mainv envv) {
sub(argc,argv,envv) ;
}
/* end subroutine (main) */


/* local subroutines */

static int sub(int argc,mainv argv,...) {
va_list ap ;
fmtspec fo ;
int rs = SR_OK ;
int rs1 ;
{
va_begin(ap,argv) ;
for (auto &sp : fmts) {
cint sl = strlen(sp) ;
if ((rs = fo.start(ap,sp,sl)) >= 0) {
{
printf("fmt=%s\n",sp) ;
printf("rs=%d\n",rs) ;
printf("w=%d\n",fo.width) ;
printf("p=%d\n",fo.prec) ;
printf("m=%d\n",fo.lenmod) ;
printf("c=%c\n",fo.fcode) ;
printf("c=%d\n",fo.skiplen) ;
}
rs1 = fo.finish ;
if (rs >= 0) rs = rs1 ;
} /* end of (fmtspec) */
} /* end for */
va_end(ap) ;
}
return rs ;
}
/* end subroutine (sub) */


0 comments on commit fb4797e

Please sign in to comment.