{"thread":{"id":"4561","subject":"[PATCH 2/7] Initialize FAMs using `FLEX_ARRAY'.","startedAt":"2006-06-18T15:18:03Z","lastAt":"2006-06-18T21:24:45Z","messageCount":4,"participants":["Florian Forster","Junio C Hamano","Timo Hirvonen"],"isPatch":true,"patchVersion":1,"patchTotal":7},"messages":[{"id":"22026","messageId":"1150643889264-git-send-email-octo@verplant.org","threadId":"4561","inReplyTo":"11506438892865-git-send-email-octo@verplant.org","subject":"[PATCH 1/7] Remove ranges from switch statements.","fromName":"Florian Forster","fromEmail":"octo@verplant.org","sentAt":"2006-06-18T15:18:03Z","receivedAt":"2006-06-18T15:18:03Z","isPatch":true,"sender":{"key":"octo@verplant.org","avatar":null},"body":"Though very nice and readable, the \"case 'a'...'z':\" construct is not ANSI C99\ncompliant. This patch unfolds the range in `quote.c' and substitutes the\nswitch-statement with an if-statement in `http-fetch.c' and `http-push.c'.\n\nSigned-off-by: Florian Forster <octo@verplant.org>\n\n\n---\n\n http-fetch.c |   13 +++++++------\n http-push.c  |   13 +++++++------\n quote.c      |    9 ++++++++-\n 3 files changed, 22 insertions(+), 13 deletions(-)\n\nd90149c5b4e91938329120bdde609e5f6d9b03e8\ndiff --git a/http-fetch.c b/http-fetch.c\nindex da1a7f5..3a2cb5e 100644\n--- a/http-fetch.c\n+++ b/http-fetch.c\n@@ -1136,13 +1136,14 @@ int fetch(unsigned char *sha1)\n \n static inline int needs_quote(int ch)\n {\n-\tswitch (ch) {\n-\tcase '/': case '-': case '.':\n-\tcase 'A'...'Z':\tcase 'a'...'z':\tcase '0'...'9':\n+\tif (((ch >= 'A') && (ch <= 'Z'))\n+\t\t\t|| ((ch >= 'a') && (ch <= 'z'))\n+\t\t\t|| ((ch >= '0') && (ch <= '9'))\n+\t\t\t|| (ch == '/')\n+\t\t\t|| (ch == '-')\n+\t\t\t|| (ch == '.'))\n \t\treturn 0;\n-\tdefault:\n-\t\treturn 1;\n-\t}\n+\treturn 1;\n }\n \n static inline int hex(int v)\ndiff --git a/http-push.c b/http-push.c\nindex 2d9441e..364ab76 100644\n--- a/http-push.c\n+++ b/http-push.c\n@@ -1077,13 +1077,14 @@ static int fetch_indices(void)\n \n static inline int needs_quote(int ch)\n {\n-\tswitch (ch) {\n-\tcase '/': case '-': case '.':\n-\tcase 'A'...'Z':\tcase 'a'...'z':\tcase '0'...'9':\n+\tif (((ch >= 'A') && (ch <= 'Z'))\n+\t\t\t|| ((ch >= 'a') && (ch <= 'z'))\n+\t\t\t|| ((ch >= '0') && (ch <= '9'))\n+\t\t\t|| (ch == '/')\n+\t\t\t|| (ch == '-')\n+\t\t\t|| (ch == '.'))\n \t\treturn 0;\n-\tdefault:\n-\t\treturn 1;\n-\t}\n+\treturn 1;\n }\n \n static inline int hex(int v)\ndiff --git a/quote.c b/quote.c\nindex 06792d4..dcc2326 100644\n--- a/quote.c\n+++ b/quote.c\n@@ -206,7 +206,14 @@ #define EMIT(c) (outp ? (*outp++ = (c)) \n \t\t\t\tcase '\\\\': case '\"':\n \t\t\t\t\tbreak; /* verbatim */\n \n-\t\t\t\tcase '0'...'7':\n+\t\t\t\tcase '0':\n+\t\t\t\tcase '1':\n+\t\t\t\tcase '2':\n+\t\t\t\tcase '3':\n+\t\t\t\tcase '4':\n+\t\t\t\tcase '5':\n+\t\t\t\tcase '6':\n+\t\t\t\tcase '7':\n \t\t\t\t\t/* octal */\n \t\t\t\t\tac = ((ch - '0') << 6);\n \t\t\t\t\tif ((ch = *sp++) < '0' || '7' < ch)\n-- \n1.3.3\n"},{"id":"22025","messageId":"11506438893796-git-send-email-octo@verplant.org","threadId":"4561","inReplyTo":"1150643889264-git-send-email-octo@verplant.org","subject":"[PATCH 2/7] Initialize FAMs using `FLEX_ARRAY'.","fromName":"Florian Forster","fromEmail":"octo@verplant.org","sentAt":"2006-06-18T15:18:04Z","receivedAt":"2006-06-18T15:18:04Z","isPatch":true,"sender":{"key":"octo@verplant.org","avatar":null},"body":"When initializing a `flexible array member' the macro `FLEX_ARRAY' should be\nused. This was forgotten in `diff-delta.c'.\n\nSigned-off-by: Florian Forster <octo@verplant.org>\n\n\n---\n\n diff-delta.c |    3 ++-\n 1 files changed, 2 insertions(+), 1 deletions(-)\n\ne587fd59510f2ed8326d280054d78cfb78d482dc\ndiff --git a/diff-delta.c b/diff-delta.c\nindex 25a798d..74486b1 100644\n--- a/diff-delta.c\n+++ b/diff-delta.c\n@@ -22,6 +22,7 @@ #include <stdlib.h>\n #include <string.h>\n #include \"delta.h\"\n \n+#include \"git-compat-util.h\"\n \n /* maximum hash entry list for the same hash bucket */\n #define HASH_LIMIT 64\n@@ -131,7 +132,7 @@ struct delta_index {\n \tconst void *src_buf;\n \tunsigned long src_size;\n \tunsigned int hash_mask;\n-\tstruct index_entry *hash[0];\n+\tstruct index_entry *hash[FLEX_ARRAY];\n };\n \n struct delta_index * create_delta_index(const void *buf, unsigned long bufsize)\n-- \n1.3.3\n"},{"id":"22040","messageId":"7vveqyyxyj.fsf@assigned-by-dhcp.cox.net","threadId":"4561","inReplyTo":"1150643889264-git-send-email-octo@verplant.org","subject":"Re: [PATCH 1/7] Remove ranges from switch statements.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-06-18T21:07:32Z","receivedAt":"2006-06-18T21:07:32Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Florian Forster <octo@verplant.org> writes:\n\n> -\tswitch (ch) {\n> -\tcase '/': case '-': case '.':\n> -\tcase 'A'...'Z':\tcase 'a'...'z':\tcase '0'...'9':\n> +\tif (((ch >= 'A') && (ch <= 'Z'))\n> +\t\t\t|| ((ch >= 'a') && (ch <= 'z'))\n> +\t\t\t|| ((ch >= '0') && (ch <= '9'))\n> + ...\n\nSorry for bringing up an old topic again, but wouldn't people\nagree that this is easier to read if it were written this way ;-)?\n \n\tif (\t   (('A' <= ch) && (ch <= 'Z'))\n        \t|| (('a' <= ch) && (ch <= 'z'))\n\t\t|| (('0' <= ch) && (ch <= '9'))\n\t...\n"},{"id":"22041","messageId":"20060619002445.3af68c2b.tihirvon@gmail.com","threadId":"4561","inReplyTo":"7vveqyyxyj.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH 1/7] Remove ranges from switch statements.","fromName":"Timo Hirvonen","fromEmail":"tihirvon@gmail.com","sentAt":"2006-06-18T21:24:45Z","receivedAt":"2006-06-18T21:24:45Z","isPatch":true,"sender":{"key":"tihirvon@gmail.com","avatar":null},"body":"Junio C Hamano <junkio@cox.net> wrote:\n\n> Sorry for bringing up an old topic again, but wouldn't people\n> agree that this is easier to read if it were written this way ;-)?\n>  \n> \tif (\t   (('A' <= ch) && (ch <= 'Z'))\n>         \t|| (('a' <= ch) && (ch <= 'z'))\n> \t\t|| (('0' <= ch) && (ch <= '9'))\n> \t...\n\nYes, but isalnum(ch) even better ;)\n\n-- \nhttp://onion.dynserv.net/~timo/\n"}]}