summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDerek Foreman <derekf@osg.samsung.com>2016-02-02 14:56:57 -0600
committerBryce Harrington <bryce@bryceharrington.org>2016-02-04 11:11:21 -0800
commit369b6466a71175289572c4ef8f70af65f620fb88 (patch)
treea1c6e3551741f644623f7328bc061643c6081c76
parent816a0ae09bd5c370b95cee459905976dc14cfac0 (diff)
downloadwayland-369b6466a71175289572c4ef8f70af65f620fb88.tar.gz
scanner: Fix oddities in copyright printing
Some copyright strings could result in broken generated header files with unmatched */ This change: Runs the loop long enough so the copyright[i] == 0 test can actually happen. (if there was no \n no copyright text was printed, */ still was) Prints the opening /* even if there was whitespace at the start of the very first line. Only emits a */ if a /* was printed. Signed-off-by: Derek Foreman <derekf@osg.samsung.com> Reviewed-by: Jon A. Cruz <jonc@osg.samsung.com> Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
-rw-r--r--src/scanner.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/scanner.c b/src/scanner.c
index dda5473..d3e2328 100644
--- a/src/scanner.c
+++ b/src/scanner.c
@@ -1284,25 +1284,29 @@ emit_structs(struct wl_list *message_list, struct interface *interface, enum sid
static void
format_copyright(const char *copyright)
{
- int bol = 1, start = 0, i;
+ int bol = 1, start = 0, i, length;
+ bool comment_started = false;
- for (i = 0; copyright[i]; i++) {
+ length = strlen(copyright);
+ for (i = 0; i <= length; i++) {
if (bol && (copyright[i] == ' ' || copyright[i] == '\t')) {
continue;
} else if (bol) {
bol = 0;
start = i;
}
-
- if (copyright[i] == '\n' || copyright[i] == '\0') {
+ if (copyright[i] == '\n' ||
+ (copyright[i] == '\0' && !(start == i))) {
printf("%s%s%.*s\n",
- i == 0 ? "/*" : " *",
+ comment_started ? " *" : "/*",
i > start ? " " : "",
i - start, copyright + start);
bol = 1;
+ comment_started = true;
}
}
- printf(" */\n\n");
+ if (comment_started)
+ printf(" */\n\n");
}
static void