]> git.alsa-project.org Git - alsa-lib.git/commitdiff
conf: List cases in range explicitly
authorMichael Forney <mforney@mforney.org>
Wed, 12 Jun 2019 06:08:10 +0000 (23:08 -0700)
committerTakashi Iwai <tiwai@suse.de>
Wed, 12 Jun 2019 06:52:24 +0000 (08:52 +0200)
Case ranges are a GNU extension, and provide only a slight readability
improvement.

Signed-off-by: Michael Forney <mforney@mforney.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
src/conf.c

index 3e4b76a34ecf2f04d600121bb1bb1c17c960033b..77fd0da506f67f188f4a343aabf8b05743d7a40c 100644 (file)
@@ -888,7 +888,8 @@ static int get_quotedchar(input_t *input)
                return '\r';
        case 'f':
                return '\f';
-       case '0' ... '7':
+       case '0': case '1': case '2': case '3':
+       case '4': case '5': case '6': case '7':
        {
                int num = c - '0';
                int i = 1;
@@ -1479,7 +1480,8 @@ static void string_print(char *str, int id, snd_output_t *out)
        }
        if (!id) {
                switch (*p) {
-               case '0' ... '9':
+               case '0': case '1': case '2': case '3': case '4':
+               case '5': case '6': case '7': case '8': case '9':
                case '-':
                        goto quoted;
                }
@@ -1488,8 +1490,6 @@ static void string_print(char *str, int id, snd_output_t *out)
        switch (*p) {
        case 0:
                goto nonquoted;
-       case 1 ... 31:
-       case 127 ... 255:
        case ' ':
        case '=':
        case ';':
@@ -1501,6 +1501,8 @@ static void string_print(char *str, int id, snd_output_t *out)
        case '"':
                goto quoted;
        default:
+               if (*p <= 31 || *p >= 127)
+                       goto quoted;
                p++;
                goto loop;
        }
@@ -1542,12 +1544,11 @@ static void string_print(char *str, int id, snd_output_t *out)
                        snd_output_putc(out, '\\');
                        snd_output_putc(out, c);
                        break;
-               case 32 ... '\'' - 1:
-               case '\'' + 1 ... 126:
-                       snd_output_putc(out, c);
-                       break;
                default:
-                       snd_output_printf(out, "\\%04o", c);
+                       if (c >= 32 && c <= 126 && c != '\'')
+                               snd_output_putc(out, c);
+                       else
+                               snd_output_printf(out, "\\%04o", c);
                        break;
                }
                p++;
@@ -4687,7 +4688,8 @@ static int parse_char(const char **ptr)
        case 'f':
                c = '\f';
                break;
-       case '0' ... '7':
+       case '0': case '1': case '2': case '3':
+       case '4': case '5': case '6': case '7':
        {
                int num = c - '0';
                int i = 1;