Skip to content

Commit c0de391

Browse files
committed
Handle %#S
1 parent a549119 commit c0de391

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

sqllib.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -488,11 +488,14 @@ void sql_vsprintf(sql_s_t * s, const char *f, va_list ap)
488488
if (s->dummy)
489489
warnx("Dummy=%llX at %s", s->dummy, f);
490490
sql_open_s(s);
491+
char backtick = 0; // Tracked for `%#S` usage, and only within the specific print
491492
while (*f)
492493
{
493494
// check enough space for anything but a string expansion...
494495
if (*f != '%')
495496
{
497+
if (*f == '`')
498+
backtick = !backtick;
496499
fputc(*f++, s->f);
497500
continue;
498501
}
@@ -545,7 +548,7 @@ void sql_vsprintf(sql_s_t * s, const char *f, va_list ap)
545548
flagformat = f;
546549
while (*f && *f != ']')
547550
f++;
548-
}
551+
}
549552
#endif
550553
else
551554
break;
@@ -604,7 +607,11 @@ void sql_vsprintf(sql_s_t * s, const char *f, va_list ap)
604607
continue;
605608
}
606609
void add(char a) { // add an escaped character
607-
if (flagalt && a == '\n')
610+
if (flagalt && a == '`' && backtick)
611+
{
612+
fputc('`', s->f);
613+
fputc('`', s->f);
614+
} else if (flagalt && a == '\n')
608615
{
609616
fputc('\\', s->f);
610617
fputc('n', s->f);
@@ -774,7 +781,7 @@ void sql_vsprintf(sql_s_t * s, const char *f, va_list ap)
774781
}
775782
}
776783
#else
777-
warnx("%%D used with no stringdecimal version - use sqllibsd.o and stringdecimal.o");
784+
warnx("%%D used with no stringdecimal version - use sqllibsd.o and stringdecimal.o");
778785
#endif
779786
break;
780787
}

0 commit comments

Comments
 (0)