Skip to content

Commit

Permalink
Replace sprint with sprintf.
Browse files Browse the repository at this point in the history
  • Loading branch information
davidgiven committed Dec 5, 2024
1 parent 1531b7d commit 3938f8a
Show file tree
Hide file tree
Showing 36 changed files with 191 additions and 207 deletions.
4 changes: 2 additions & 2 deletions lang/basic/src/symbols.c
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ void heading(void)
{
char procname[50];

(void) sprint(procname,"_%s",fcn->symname);
(void) sprintf(procname,"_%s",fcn->symname);
C_pro_narg(procname);
if ( fcn->symtype== DEFAULTTYPE)
fcn->symtype= DOUBLETYPE;
Expand Down Expand Up @@ -348,7 +348,7 @@ int fcnend(int parmcount)
error("not enough parameters");
if ( parmcount >fcn->dimensions)
error("too many parameters");
(void) sprint(concatbuf,"_%s",fcn->symname);
(void) sprintf(concatbuf,"_%s",fcn->symname);
C_cal(concatbuf);
C_asp((arith)fcnsize());
C_lfr((arith) typestring(fcn->symtype));
Expand Down
2 changes: 1 addition & 1 deletion lang/basic/src/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ char *myitoa(int i)
{
static char buf[30];

sprint(buf,"%d",i);
sprintf(buf,"%d",i);
return(buf);
}

Expand Down
24 changes: 12 additions & 12 deletions lang/cem/cemcom.ansi/dumpidf.c
Original file line number Diff line number Diff line change
Expand Up @@ -324,37 +324,37 @@ static char *type2str(struct type *tp)

buf[0] = '\0';
if (!tp) {
sprint(buf, "<NILTYPE>");
sprintf(buf, "<NILTYPE>");
return buf;
}
sprint(buf, "%s(@%lx, #%ld, &%d) ",
sprintf(buf, "%s(@%lx, #%ld, &%d) ",
buf, tp, (long)tp->tp_size, tp->tp_align);

while (ops) {
sprint(buf, "%s%s", buf, qual2str(tp->tp_typequal));
sprintf(buf, "%s%s", buf, qual2str(tp->tp_typequal));
switch (tp->tp_fund) {
case POINTER:
sprint(buf, "%spointer to ", buf);
sprintf(buf, "%spointer to ", buf);
break;
case ARRAY:
sprint(buf, "%sarray [%ld] of ", buf, tp->tp_size);
sprintf(buf, "%sarray [%ld] of ", buf, tp->tp_size);
break;
case FUNCTION:
sprint(buf, "%sfunction yielding ", buf);
sprintf(buf, "%sfunction yielding ", buf);
break;
default:
sprint(buf, "%s%s%s ", buf,
sprintf(buf, "%s%s%s ", buf,
tp->tp_unsigned ? "unsigned " : "",
symbol2str(tp->tp_fund)
);
if (tp->tp_idf)
sprint(buf, "%s %s ", buf,
sprintf(buf, "%s %s ", buf,
tp->tp_idf->id_text);
#ifndef NOBITFIELD
if (tp->tp_fund == FIELD && tp->tp_field) {
struct field *fd = tp->tp_field;

sprint(buf, "%s [s=%ld,w=%ld] of ", buf,
sprintf(buf, "%s [s=%ld,w=%ld] of ", buf,
fd->fd_shift, fd->fd_width);
}
else
Expand All @@ -373,11 +373,11 @@ static char *qual2str(int qual)

*buf = '\0';
if (qual == 0)
sprint(buf, "(none)");
sprintf(buf, "(none)");
if (qual & TQ_CONST)
sprint(buf, "%sconst ", buf);
sprintf(buf, "%sconst ", buf);
if (qual & TQ_VOLATILE)
sprint(buf, "%svolatile ", buf);
sprintf(buf, "%svolatile ", buf);

return qual == 0 ? "" : buf;
}
Expand Down
2 changes: 1 addition & 1 deletion lang/cem/cemcom.ansi/idf.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ struct idf *gen_idf(void)
static int name_cnt;
char *s = malloc(strlen(dot.tk_file) + 50);

sprint(s, "#%d in %s, line %u", ++name_cnt, dot.tk_file, dot.tk_line);
sprintf(s, "#%d in %s, line %u", ++name_cnt, dot.tk_file, dot.tk_line);
s = realloc(s, strlen(s) + 1);
return str2idf(s, 0);
}
Expand Down
2 changes: 1 addition & 1 deletion lang/cem/cemcom/arith.c
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ int2float(expp, tp)
if (is_cp_cst(exp)) {
*expp = new_expr();
**expp = *exp;
sprint(buf+1, "%ld", (long)(exp->VL_VALUE));
sprintf(buf+1, "%ld", (long)(exp->VL_VALUE));
buf[0] = '-';
exp = *expp;
exp->ex_type = tp;
Expand Down
16 changes: 8 additions & 8 deletions lang/cem/cemcom/dumpidf.c
Original file line number Diff line number Diff line change
Expand Up @@ -249,35 +249,35 @@ type2str(tp)

buf[0] = '\0';
if (!tp) {
sprint(buf, "<NILTYPE>");
sprintf(buf, "<NILTYPE>");
return buf;
}

sprint(buf, "%s(#%ld, &%d) ", buf, (long)tp->tp_size, tp->tp_align);
sprintf(buf, "%s(#%ld, &%d) ", buf, (long)tp->tp_size, tp->tp_align);
while (ops) {
switch (tp->tp_fund) {
case POINTER:
sprint(buf, "%spointer to ", buf);
sprintf(buf, "%spointer to ", buf);
break;
case ARRAY:
sprint(buf, "%sarray [%ld] of ", buf, tp->tp_size);
sprintf(buf, "%sarray [%ld] of ", buf, tp->tp_size);
break;
case FUNCTION:
sprint(buf, "%sfunction yielding ", buf);
sprintf(buf, "%sfunction yielding ", buf);
break;
default:
sprint(buf, "%s%s%s", buf,
sprintf(buf, "%s%s%s", buf,
tp->tp_unsigned ? "unsigned " : "",
symbol2str(tp->tp_fund)
);
if (tp->tp_idf)
sprint(buf, "%s %s", buf,
sprintf(buf, "%s %s", buf,
tp->tp_idf->id_text);
#ifndef NOBITFIELD
if (tp->tp_field) {
struct field *fd = tp->tp_field;

sprint(buf, "%s [s=%ld,w=%ld] of ", buf,
sprintf(buf, "%s [s=%ld,w=%ld] of ", buf,
fd->fd_shift, fd->fd_width);
}
else
Expand Down
2 changes: 1 addition & 1 deletion lang/cem/cemcom/idf.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ gen_idf()
struct idf *id;
char *s = malloc(strlen(dot.tk_file)+50);

sprint(s, "#%d in %s, line %u",
sprintf(s, "#%d in %s, line %u",
++name_cnt, dot.tk_file, dot.tk_line);
id = str2idf(s);
free(s);
Expand Down
4 changes: 2 additions & 2 deletions lang/cem/cpp.ansi/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,13 @@ void init_pp(void)
tp = localtime(&clock);

/* __DATE__ */
sprint(dbuf, "\"%s %2d %d\"", months[tp->tm_mon],
sprintf(dbuf, "\"%s %2d %d\"", months[tp->tm_mon],
tp->tm_mday, tp->tm_year+1900);
/* if (tp->tm_mday < 10) dbuf[5] = ' '; */ /* hack */
macro_def(str2idf("__DATE__", 0), dbuf, -1, strlen(dbuf), NOUNDEF);

/* __TIME__ */
sprint(tbuf, "\"%02d:%02d:%02d\"", tp->tm_hour, tp->tm_min, tp->tm_sec);
sprintf(tbuf, "\"%02d:%02d:%02d\"", tp->tm_hour, tp->tm_min, tp->tm_sec);
macro_def(str2idf("__TIME__", 0), tbuf, -1, strlen(tbuf), NOUNDEF);

/* __LINE__ */
Expand Down
4 changes: 2 additions & 2 deletions lang/cem/cpp.ansi/preprocess.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ void preprocess(char *fn)
*/
char* p = Xbuf;

sprint(p, "%s 1 \"%s\"\n", LINE_PREFIX, FileName);
sprintf(p, "%s 1 \"%s\"\n", LINE_PREFIX, FileName);
while (*p)
{
echo(*p++);
Expand All @@ -172,7 +172,7 @@ void preprocess(char *fn)
if (!options['P']) \
{ \
char* p = Xbuf; \
sprint(Xbuf, "%s %d \"%s\"\n", LINE_PREFIX, (int)LineNumber, FileName); \
sprintf(Xbuf, "%s %d \"%s\"\n", LINE_PREFIX, (int)LineNumber, FileName); \
op--; \
while (op >= _obuf && (class(*op) == STSKIP || *op == '\n')) \
op--; \
Expand Down
2 changes: 1 addition & 1 deletion lang/cem/lint/lpass2/l_print3ack.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ print(format) char *format; { ; }
/* FORMAT1 */
fprint(filep, format) File *filep; char *format; { ; }
/* FORMAT1 */
sprint(s, format) char *s; char *format; { ; }
sprintf(s, format) char *s; char *format; { ; }
/* FORMAT1 */
doprnt(filep, format) File *filep; char *format; { ; }

Expand Down
6 changes: 3 additions & 3 deletions lang/m2/comp/def.c
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ struct def * DeclProc(int type, struct idf *id)
}
else
{
sprint(buf, "%s_%s", CurrentScope->sc_name, id->id_text);
sprintf(buf, "%s_%s", CurrentScope->sc_name, id->id_text);
df->prc_name = Salloc(buf, (unsigned) (strlen(buf) + 1));
}
if (CurrVis == Defined->mod_vis)
Expand All @@ -311,7 +311,7 @@ struct def * DeclProc(int type, struct idf *id)
else
{
df = define(id, CurrentScope, type);
sprint(buf, "_%d_%s", ++nmcount, id->id_text);
sprintf(buf, "_%d_%s", ++nmcount, id->id_text);
df->prc_name = Salloc(buf, (unsigned) (strlen(buf) + 1));
internal(buf);
df->df_flags |= D_DEFINED;
Expand Down Expand Up @@ -355,7 +355,7 @@ struct def * DefineLocalModule(struct idf *id)
char buf[256];
extern int proclevel;

sprint(buf, "_%d%s_", ++modulecount, id->id_text);
sprintf(buf, "_%d%s_", ++modulecount, id->id_text);

if (!df->mod_vis)
{
Expand Down
2 changes: 1 addition & 1 deletion lang/m2/comp/enter.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ void EnterVarList(struct node *Idlist, struct type *type, int local)
df->var_name = df->df_idf->id_text;
}
else {
sprint(buf,"%s_%s", sc->sc_scope->sc_name,
sprintf(buf,"%s_%s", sc->sc_scope->sc_name,
df->df_idf->id_text);
df->var_name = Salloc(buf,
(unsigned)(strlen(buf)+1));
Expand Down
2 changes: 1 addition & 1 deletion lang/m2/comp/misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ struct idf *gen_anon_idf(void)
static int name_cnt;
char *s = malloc(strlen(FileName)+50);

sprint(s, "#%d in %s, line %u",
sprintf(s, "#%d in %s, line %u",
++name_cnt, FileName, LineNumber);
s = realloc(s, strlen(s)+1);
return str2idf(s, 0);
Expand Down
2 changes: 1 addition & 1 deletion lang/m2/comp/program.g
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ DefinitionModule
error("DEFINITION MODULE name is \"%s\", not \"%s\"",
df->df_idf->id_text, DefId->id_text);
}
sprint(buf, "_%s_", df->df_idf->id_text);
sprintf(buf, "_%s_", df->df_idf->id_text);
currscope->sc_name = Salloc(buf, (unsigned) strlen(buf) + 1);
df->mod_vis = CurrVis;
df->df_type = standard_type(T_RECORD, 1, (arith) 1);
Expand Down
Loading

0 comments on commit 3938f8a

Please sign in to comment.