summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLukas Fleischer <calcurse@cryptocrack.de>2011-08-26 12:07:11 +0200
committerLukas Fleischer <calcurse@cryptocrack.de>2011-08-26 12:14:03 +0200
commitb59070a49e292746edeb781733db25931a6a6e50 (patch)
tree75c8d540fae0b18dd1157911291ff7066b40d691
parent806a13ed8a23eeda97f50e4a9e0dd0fc5988efa7 (diff)
downloadcalcurse-b59070a49e292746edeb781733db25931a6a6e50.tar.gz
calcurse-b59070a49e292746edeb781733db25931a6a6e50.zip
Rework indentation code in print_notefile()
Do not use snprintf() here as printf() behaviour is undefined if the destination pointer is used as a parameter. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
-rw-r--r--src/args.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/args.c b/src/args.c
index e447997..a3a22fe 100644
--- a/src/args.c
+++ b/src/args.c
@@ -199,13 +199,19 @@ print_notefile (FILE *out, char *filename, int nbtab)
{
char path_to_notefile[BUFSIZ];
FILE *notefile;
- char linestarter[BUFSIZ] = "";
+ char linestarter[BUFSIZ];
char buffer[BUFSIZ];
int i;
int printlinestarter = 1;
- for (i = 0; i < nbtab; i++)
- (void)snprintf(linestarter, BUFSIZ, "%s\t", linestarter);
+ if (nbtab < BUFSIZ)
+ {
+ for (i = 0; i < nbtab; i++)
+ linestarter[i] = '\t';
+ linestarter[nbtab] = '\0';
+ }
+ else
+ linestarter[0] = '\0';
(void)snprintf (path_to_notefile, BUFSIZ, "%s/%s", path_notes, filename);
notefile = fopen (path_to_notefile, "r");