Skip to content

Commit

Permalink
Remove all formatting from string
Browse files Browse the repository at this point in the history
  • Loading branch information
vmcj committed Jan 24, 2022
1 parent d02b0f5 commit 79bdef2
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion lib/lib.error.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,21 @@ void vlogmsg(int msglevel, const char *mesg, va_list ap)
bufferlen = strlen(timestring)+strlen(progname_escaped)+strlen(mesg)+20;
buffer = (char *)malloc(bufferlen);
if ( buffer==NULL ) abort();
progname_unformatted = (char *)malloc(1+strlen(progname_escaped));
size_t str_tmp_pos, esc_tmp_pos;
char ctmp;
for(str_tmp_pos=0; str_tmp_pos<strlen(progname_escaped); str_tmp_pos++) {
ctmp = progname_escaped[str_tmp_pos];
if ( ctmp!='%' ) {
progname_unformatted[esc_tmp_pos++] = ctmp;
}
}
progname_unformatted[esc_tmp_pos] = 0;

snprintf(buffer, bufferlen, "[%s] %s[%d]: %s\n",
timestring, progname_escaped, getpid(), mesg);
timestring, progname_unformatted, getpid(), mesg);

free(progname_unformatted);
free(progname_escaped);

if ( msglevel<=verbose ) {
Expand Down

0 comments on commit 79bdef2

Please sign in to comment.