era eriksson @ Fri, Feb 25, 2005 at 11:21:03AM +0200:

> Version: 4.1.2-1
> Severity: minor
> Tags: upstream
> 
> Not actually sure if this is valid syntax or not (I guess not), but
> the error message is absurd:
> 
>  $ sed 'c\' /etc/motd
>  sed: couldn't write -1 items to stdout: Success
> 
> /* era */


[EMAIL PROTECTED] echo | sed 'c\'
sed: couldn't write -1 items to stdout: Success
[EMAIL PROTECTED] echo | sed 'i\'
sed: couldn't write -1 items to stdout: Success
[EMAIL PROTECTED] echo | sed 'a\'

[EMAIL PROTECTED]
[EMAIL PROTECTED] echo | /tmp/sed 'a\'
/tmp/sed: -e expression #1, char 2: missing command
[EMAIL PROTECTED] echo | /tmp/sed 'i\'
/tmp/sed: -e expression #1, char 2: missing command
[EMAIL PROTECTED] echo | /tmp/sed 'c\'
/tmp/sed: -e expression #1, char 2: missing command
[EMAIL PROTECTED]
[EMAIL PROTECTED] echo | /tmp/sed 'i\
> olecom
> '
olecom

[EMAIL PROTECTED] echo | /tmp/sed 'a\
> olecom
> '

olecom
[EMAIL PROTECTED] echo | /tmp/sed 'c\
olecom
'
olecom
[EMAIL PROTECTED]


Patch is with emacs's tabify && strip-trailing-whitespace
(for C it's nothing)


Actual change:

@@ -1160,9 +1160,13 @@ compile_program(vector)
        read_text_to_slash:
          if (ch == EOF)
            bad_prog(_(EXPECTED_SLASH));
-             
+
          if (ch == '\\')
-           ch = inchar();
+           {
+             ch = inchar();
+             if (ch == EOF)
+               bad_prog(_(NO_COMMAND));
+           }

WTFPL-ed-by: olecom
Please, see: http://sam.zoy.org/wtfpl/


diff -uprN /mnt/work/pc/src-build/debian/sed/sed-4.1.5/sed/compile.c\~ 
/mnt/work/pc/src-build/debian/sed/sed-4.1.5/sed/compile.c
--- /mnt/work/pc/src-build/debian/sed/sed-4.1.5/sed/compile.c~  2006-02-03 
10:06:26.000000000 +0100
+++ /mnt/work/pc/src-build/debian/sed/sed-4.1.5/sed/compile.c   2008-04-10 
23:28:16.885183500 +0200
@@ -396,17 +396,17 @@ get_openfile(file_ptrs, mode, fail)
     {
       /* Check whether it is a special file (stdin, stdout or stderr) */
       struct special_files *special = special_files;
-                 
+
       /* std* sometimes are not constants, so they
-         cannot be used in the initializer for special_files */
+        cannot be used in the initializer for special_files */
       my_stdin = stdin; my_stdout = stdout; my_stderr = stderr;
       for (special = special_files; special->outf.name; special++)
-        if (strcmp(special->outf.name, file_name) == 0)
-          {
+       if (strcmp(special->outf.name, file_name) == 0)
+         {
            special->outf.fp = *special->pfp;
            free_buffer (b);
            return &special->outf;
-          }
+         }
     }
 
   if (!p)
@@ -459,13 +459,13 @@ snarf_char_class(b, cur_stat)
   int state = 0;
   int delim;
   bool pending_mb = 0;
-  
+
   ch = inchar();
   if (ch == '^')
     ch = add_then_next(b, ch);
   if (ch == CLOSE_BRACKET)
     ch = add_then_next(b, ch);
-  
+
   /* States are:
        0 outside a collation element, character class or collation class
        1 after the bracket
@@ -523,8 +523,8 @@ snarf_char_class(b, cur_stat)
        }
 
       /* Getting a character different from .=: whilst in state 1
-         goes back to state 0, getting a character different from ]
-         whilst in state 3 goes back to state 2.  */
+        goes back to state 0, getting a character different from ]
+        whilst in state 3 goes back to state 2.  */
       state &= ~1;
     }
 }
@@ -562,20 +562,20 @@ match_slash(slash, regex)
            {
              ch = inchar();
              if (ch == EOF)
-               break;
+               break;
 #ifndef REG_PERL
              else if (ch == 'n' && regex)
-               ch = '\n';
+               ch = '\n';
 #endif
              else if (ch != '\n' && ch != slash)
-               add1_buffer(b, '\\');
+               add1_buffer(b, '\\');
            }
-          else if (ch == OPEN_BRACKET && regex)
+         else if (ch == OPEN_BRACKET && regex)
            {
              add1_buffer(b, ch);
              ch = snarf_char_class(b, &cur_stat);
              if (ch != CLOSE_BRACKET)
-               break;
+               break;
            }
        }
 
@@ -800,8 +800,8 @@ setup_replacement(sub, text, length)
          if (p < text_end && (posixicity != POSIXLY_BASIC || ISDIGIT (*p)))
            switch (*p)
              {
-             case '0': case '1': case '2': case '3': case '4': 
-             case '5': case '6': case '7': case '8': case '9': 
+             case '0': case '1': case '2': case '3': case '4':
+             case '5': case '6': case '7': case '8': case '9':
                tail->subst_id = *p - '0';
                if (sub->max_id < tail->subst_id)
                  sub->max_id = tail->subst_id;
@@ -816,7 +816,7 @@ setup_replacement(sub, text, length)
                repl_type = REPL_UPPERCASE;
                save_type = REPL_UPPERCASE;
                break;
-               
+
              case 'E':
                repl_type = REPL_ASIS;
                save_type = REPL_ASIS;
@@ -831,7 +831,7 @@ setup_replacement(sub, text, length)
                save_type = repl_type;
                repl_type |= REPL_UPPERCASE_FIRST;
                break;
-               
+
              default:
                p[-1] = *p;
                ++tail->prefix_length;
@@ -943,7 +943,7 @@ compile_address(addr, ch)
       for(;;)
        {
          ch = in_nonblank();
-          switch(ch)
+         switch(ch)
            {
            case 'I':   /* GNU extension */
              flags |= REG_ICASE;
@@ -1087,7 +1087,7 @@ compile_program(vector)
            case 'a': case 'i': case 'l':
            case '=': case 'r':
              if (cur_cmd->a2)
-               bad_prog(_(ONE_ADDR));
+               bad_prog(_(ONE_ADDR));
          }
 
       cur_cmd->cmd = ch;
@@ -1160,9 +1160,13 @@ compile_program(vector)
        read_text_to_slash:
          if (ch == EOF)
            bad_prog(_(EXPECTED_SLASH));
-             
+
          if (ch == '\\')
-           ch = inchar();
+           {
+             ch = inchar();
+             if (ch == EOF)
+               bad_prog(_(NO_COMMAND));
+           }
          else
            {
              savchar(ch);
@@ -1177,7 +1181,7 @@ compile_program(vector)
            bad_prog(_(NO_COLON_ADDR));
          labels = setup_label(labels, vector->v_length, read_label(), NULL);
          break;
-       
+
        case 'T':
        case 'b':
        case 't':
@@ -1193,7 +1197,7 @@ compile_program(vector)
        case 'L':
        case 'l':
          ch = in_nonblank();
-         if (ISDIGIT(ch)) 
+         if (ISDIGIT(ch))
            {
              cur_cmd->x.int_arg = in_integer(ch);
              ch = in_nonblank();
@@ -1233,11 +1237,11 @@ compile_program(vector)
          free_buffer(b);
          break;
 
-        case 'R':
+       case 'R':
          cur_cmd->x.fp = get_openfile(&file_read, "r", false)->fp;
          break;
 
-        case 'W':
+       case 'W':
        case 'w':
          cur_cmd->x.outf = get_openfile(&file_write, "w", true);
          break;
@@ -1271,102 +1275,102 @@ compile_program(vector)
            size_t len, dest_len;
            int slash;
            struct buffer *b2;
-            char *src_buf, *dest_buf;
-  
+           char *src_buf, *dest_buf;
+
            slash = inchar();
            if ( !(b = match_slash(slash, false)) )
              bad_prog(_(UNTERM_Y_CMD));
-            src_buf = get_buffer(b);
+           src_buf = get_buffer(b);
            len = normalize_text(src_buf, size_buffer (b), TEXT_BUFFER);
 
-            if ( !(b2 = match_slash(slash, false)) )
-             bad_prog(_(UNTERM_Y_CMD));
-            dest_buf = get_buffer(b2);
+           if ( !(b2 = match_slash(slash, false)) )
+             bad_prog(_(UNTERM_Y_CMD));
+           dest_buf = get_buffer(b2);
            dest_len = normalize_text(dest_buf, size_buffer (b2), TEXT_BUFFER);
 
-            if (mb_cur_max > 1)
+           if (mb_cur_max > 1)
+             {
+               int i, j, idx, src_char_num;
+               size_t *src_lens = MALLOC(len, size_t);
+               char **trans_pairs;
+               size_t mbclen;
+               mbstate_t cur_stat;
+
+               /* Enumerate how many character the source buffer has.  */
+               memset(&cur_stat, 0, sizeof(mbstate_t));
+               for (i = 0, j = 0; i < len;)
+                 {
+                   mbclen = MBRLEN (src_buf + i, len - i, &cur_stat);
+                   /* An invalid sequence, or a truncated multibyte character.
+                      We treat it as a singlebyte character.  */
+                   if (mbclen == (size_t) -1 || mbclen == (size_t) -2
+                       || mbclen == 0)
+                     mbclen = 1;
+                   src_lens[j++] = mbclen;
+                   i += mbclen;
+                 }
+               src_char_num = j;
+
+               memset(&cur_stat, 0, sizeof(mbstate_t));
+               idx = 0;
+
+               /* trans_pairs = {src(0), dest(0), src(1), dest(1), ..., NULL}
+                    src(i) : pointer to i-th source character.
+                    dest(i) : pointer to i-th destination character.
+                    NULL : terminator */
+               trans_pairs = MALLOC(2 * src_char_num + 1, char*);
+               cur_cmd->x.translatemb = trans_pairs;
+               for (i = 0; i < src_char_num; i++)
+                 {
+                   if (idx >= dest_len)
+                     bad_prog(_(Y_CMD_LEN));
+
+                   /* Set the i-th source character.  */
+                   trans_pairs[2 * i] = MALLOC(src_lens[i] + 1, char);
+                   strncpy(trans_pairs[2 * i], src_buf, src_lens[i]);
+                   trans_pairs[2 * i][src_lens[i]] = '\0';
+                   src_buf += src_lens[i]; /* Forward to next character.  */
+
+                   /* Fetch the i-th destination character.  */
+                   mbclen = MBRLEN (dest_buf + idx, dest_len - idx, &cur_stat);
+                   /* An invalid sequence, or a truncated multibyte character.
+                      We treat it as a singlebyte character.  */
+                   if (mbclen == (size_t) -1 || mbclen == (size_t) -2
+                       || mbclen == 0)
+                     mbclen = 1;
+
+                   /* Set the i-th destination character.  */
+                   trans_pairs[2 * i + 1] = MALLOC(mbclen + 1, char);
+                   strncpy(trans_pairs[2 * i + 1], dest_buf + idx, mbclen);
+                   trans_pairs[2 * i + 1][mbclen] = '\0';
+                   idx += mbclen; /* Forward to next character.  */
+                 }
+               trans_pairs[2 * i] = NULL;
+               if (idx != dest_len)
+                 bad_prog(_(Y_CMD_LEN));
+             }
+           else
              {
-                int i, j, idx, src_char_num;
-                size_t *src_lens = MALLOC(len, size_t);
-                char **trans_pairs;
-                size_t mbclen;
-                mbstate_t cur_stat;
-
-                /* Enumerate how many character the source buffer has.  */
-                memset(&cur_stat, 0, sizeof(mbstate_t));
-                for (i = 0, j = 0; i < len;)
-                  {
-                    mbclen = MBRLEN (src_buf + i, len - i, &cur_stat);
-                    /* An invalid sequence, or a truncated multibyte character.
-                       We treat it as a singlebyte character.  */
-                    if (mbclen == (size_t) -1 || mbclen == (size_t) -2
-                        || mbclen == 0)
-                      mbclen = 1;
-                    src_lens[j++] = mbclen;
-                    i += mbclen;
-                  }
-                src_char_num = j;
-
-                memset(&cur_stat, 0, sizeof(mbstate_t));
-                idx = 0;
-
-                /* trans_pairs = {src(0), dest(0), src(1), dest(1), ..., NULL}
-                     src(i) : pointer to i-th source character.
-                     dest(i) : pointer to i-th destination character.
-                     NULL : terminator */
-                trans_pairs = MALLOC(2 * src_char_num + 1, char*);
-                cur_cmd->x.translatemb = trans_pairs;
-                for (i = 0; i < src_char_num; i++)
-                  {
-                    if (idx >= dest_len)
-                      bad_prog(_(Y_CMD_LEN));
-
-                    /* Set the i-th source character.  */
-                    trans_pairs[2 * i] = MALLOC(src_lens[i] + 1, char);
-                    strncpy(trans_pairs[2 * i], src_buf, src_lens[i]);
-                    trans_pairs[2 * i][src_lens[i]] = '\0';
-                    src_buf += src_lens[i]; /* Forward to next character.  */
-
-                    /* Fetch the i-th destination character.  */
-                    mbclen = MBRLEN (dest_buf + idx, dest_len - idx, 
&cur_stat);
-                    /* An invalid sequence, or a truncated multibyte character.
-                       We treat it as a singlebyte character.  */
-                    if (mbclen == (size_t) -1 || mbclen == (size_t) -2
-                        || mbclen == 0)
-                      mbclen = 1;
-
-                    /* Set the i-th destination character.  */
-                    trans_pairs[2 * i + 1] = MALLOC(mbclen + 1, char);
-                    strncpy(trans_pairs[2 * i + 1], dest_buf + idx, mbclen);
-                    trans_pairs[2 * i + 1][mbclen] = '\0';
-                    idx += mbclen; /* Forward to next character.  */
-                  }
-                trans_pairs[2 * i] = NULL;
-                if (idx != dest_len)
-                  bad_prog(_(Y_CMD_LEN));
-              }
-            else
-              {
-               char *translate = OB_MALLOC(&obs, YMAP_LENGTH, char);
-                unsigned char *ustring = CAST(unsigned char *)src_buf;
+               char *translate = OB_MALLOC(&obs, YMAP_LENGTH, char);
+               unsigned char *ustring = CAST(unsigned char *)src_buf;
 
                if (len != dest_len)
-                  bad_prog(_(Y_CMD_LEN));
+                 bad_prog(_(Y_CMD_LEN));
 
-               for (len = 0; len < YMAP_LENGTH; len++)
-                 translate[len] = len;
+               for (len = 0; len < YMAP_LENGTH; len++)
+                 translate[len] = len;
 
-                while (dest_len--)
-                  translate[(unsigned char)*ustring++] = *dest_buf++;
+               while (dest_len--)
+                 translate[(unsigned char)*ustring++] = *dest_buf++;
 
-               cur_cmd->x.translate = translate;
+               cur_cmd->x.translate = translate;
              }
 
-            if ((ch = in_nonblank()) != EOF && ch != '\n' && ch != ';')
-              bad_prog(_(EXCESS_JUNK));
+           if ((ch = in_nonblank()) != EOF && ch != '\n' && ch != ';')
+             bad_prog(_(EXCESS_JUNK));
 
-            free_buffer(b);
-            free_buffer(b2);
+           free_buffer(b);
+           free_buffer(b2);
          }
        break;
 
@@ -1415,14 +1419,14 @@ normalize_text(buf, len, buftype)
       mbclen = MBRLEN (p, bufend - p, &cur_stat);
       if (mbclen != 1)
        {
-          /* An invalid sequence, or a truncated multibyte character.
-             We treat it as a singlebyte character.  */
-          if (mbclen == (size_t) -1 || mbclen == (size_t) -2 || mbclen == 0)
-            mbclen = 1;
-
-          memmove (q, p, mbclen);
-          q += mbclen;
-          p += mbclen;
+         /* An invalid sequence, or a truncated multibyte character.
+            We treat it as a singlebyte character.  */
+         if (mbclen == (size_t) -1 || mbclen == (size_t) -2 || mbclen == 0)
+           mbclen = 1;
+
+         memmove (q, p, mbclen);
+         q += mbclen;
+         p += mbclen;
          continue;
        }
 
@@ -1465,7 +1469,7 @@ normalize_text(buf, len, buftype)
            else
              {
                /* we just pass the \ up one level for interpretation */
-               if (buftype != TEXT_BUFFER)
+               if (buftype != TEXT_BUFFER)
                  *q++ = '\\';
              }
 
@@ -1474,16 +1478,16 @@ normalize_text(buf, len, buftype)
          case 'o': /* octal byte */
            if (!(extended_regexp_flags & REG_PERL))
              {
-               p = convert_number(q, p+1, bufend,  8, 3, 'o');
+               p = convert_number(q, p+1, bufend,  8, 3, 'o');
                q++;
              }
            else
              {
-               /* we just pass the \ up one level for interpretation */
-               if (buftype != TEXT_BUFFER)
+               /* we just pass the \ up one level for interpretation */
+               if (buftype != TEXT_BUFFER)
                  *q++ = '\\';
              }
-           
+
            continue;
 #else
          case 'o': /* octal byte */
@@ -1501,10 +1505,10 @@ normalize_text(buf, len, buftype)
              }
            else
              {
-               /* we just pass the \ up one level for interpretation */
-               if (buftype != TEXT_BUFFER)
+               /* we just pass the \ up one level for interpretation */
+               if (buftype != TEXT_BUFFER)
                  *q++ = '\\';
-               continue;
+               continue;
              }
 
          default:
@@ -1514,29 +1518,29 @@ normalize_text(buf, len, buftype)
            break;
          }
       else if (buftype == TEXT_REGEX && posixicity != POSIXLY_EXTENDED)
-        switch (*p)
-          {
-          case '[':
-            if (!bracket_state)
-              bracket_state = -1;
-            break;
- 
+       switch (*p)
+         {
+         case '[':
+           if (!bracket_state)
+             bracket_state = -1;
+           break;
+
          case ':':
          case '.':
          case '=':
-            if (bracket_state == -1 && p[-1] == '[')
-              bracket_state = *p;
-            break;
+           if (bracket_state == -1 && p[-1] == '[')
+             bracket_state = *p;
+           break;
 
-          case ']':
-            if (bracket_state == 0)
+         case ']':
+           if (bracket_state == 0)
              ;
-            else if (bracket_state == -1)
-              bracket_state = 0;
-            else if (p[-2] != bracket_state && p[-1] == bracket_state)
-              bracket_state = -1;
-            break;
-          }
+           else if (bracket_state == -1)
+             bracket_state = 0;
+           else if (p[-2] != bracket_state && p[-1] == bracket_state)
+             bracket_state = -1;
+           break;
+         }
 
       *q++ = *p++;
     }

Diff finished at Thu Apr 10 23:43:43



-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to