From 50e7b06730915dd7439e880fe84439a4483ccbb4 Mon Sep 17 00:00:00 2001 From: Pavel Roskin Date: Wed, 21 Dec 2005 15:35:48 -0500 Subject: [PATCH] quote.c: Make loop control more readable. quote_c_style_counted() in quote.c uses a hard-to-read construct. Convert this to a more traditional form of the for loop. Signed-off-by: Pavel Roskin Signed-off-by: Junio C Hamano diff --git a/quote.c b/quote.c index 76eb144..7218a70 100644 --- a/quote.c +++ b/quote.c @@ -126,8 +126,10 @@ static int quote_c_style_counted(const char *name, int namelen, if (!no_dq) EMIT('"'); - for (sp = name; (ch = *sp++) && (sp - name) <= namelen; ) { - + for (sp = name; sp < name + namelen; sp++) { + ch = *sp; + if (!ch) + break; if ((ch < ' ') || (ch == '"') || (ch == '\\') || (ch == 0177)) { needquote = 1; -- cgit v0.10.2-6-g49f6 From 8ac4838af428a2a32498b3e8d13295eb714654b4 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Wed, 21 Dec 2005 13:48:47 -0800 Subject: server-info: skip empty lines. Now we allow an empty line in objects/info/packs file, recognize that and stop complaining. Signed-off-by: Junio C Hamano diff --git a/server-info.c b/server-info.c index 6089765..05bce7d 100644 --- a/server-info.c +++ b/server-info.c @@ -99,7 +99,10 @@ static int read_pack_info_file(const char *infofile) while (fgets(line, sizeof(line), fp)) { int len = strlen(line); if (line[len-1] == '\n') - line[len-1] = 0; + line[--len] = 0; + + if (!len) + continue; switch (line[0]) { case 'P': /* P name */ -- cgit v0.10.2-6-g49f6