Author: blues                        Date: Thu Mar 29 14:50:45 2007 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
- stollen from SuSE

---- Files affected:
SOURCES:
   pine-utf8-1a-GFHP_HANDLES.patch (NONE -> 1.1)  (NEW), 
pine-utf8-1a-pine.h.patch (NONE -> 1.1)  (NEW), pine-utf8-1b.patch (NONE -> 
1.1)  (NEW)

---- Diffs:

================================================================
Index: SOURCES/pine-utf8-1a-GFHP_HANDLES.patch
diff -u /dev/null SOURCES/pine-utf8-1a-GFHP_HANDLES.patch:1.1
--- /dev/null   Thu Mar 29 16:50:45 2007
+++ SOURCES/pine-utf8-1a-GFHP_HANDLES.patch     Thu Mar 29 16:50:40 2007
@@ -0,0 +1,51 @@
+Changelog:
+
+The two changes are related to a development effort to
+make html2plain aware of UTF-8, but it turned out to
+be very complex and a quick hack to disable wrapping
+in it and delay wrapping to gf_warp which is aware of
+UTF-8 did not work well because html has also center
+and right oriented wrapping, which gf_wrap has no
+idea of. The removed parts cleanup the leftovers of
+this attempt:
+
+  * GFHP_NOWRAP was not evaluated, it it made no no
+    sense to set it (checked the evaluation of opts)
+
+  * Since wrapping in html2wrap was not disabled,
+    it is no longer neccessary to remove the wrapit = 0
+    which told the code to add gf_wrap to the pipe
+    to apply wrapping.
+
+  * Remove the #define of GFHP_HANDLES which is
+    is made obsolete by the remaining cleanup.
+    It can be cleaned up because the handlesp
+    flag is passed directly to html2plain, no
+    longer thru the opts bitfield and this opts
+    value is not evaluated otherwise (checked).
+    This hunk was only moved from a different
+    patch file here to consolidate this cleanup.
+
+--- pine4.59.9z/pine/mailview.c
++++ pine4.59.9d/pine/mailview.c
+@@ -5640,9 +5650,5 @@ decode_text(att, msgno, pc, handlesp, st
+       int opts = 0;
+ 
+-      if(flags & FM_DISPLAY){
+-          if(handlesp)                /* pass on handles awareness */
+-            opts |= GFHP_HANDLES;
+-      }
+-      else
++      if(!(flags & FM_DISPLAY))
+         opts |= GFHP_STRIPPED;        /* don't embed anything! */
+ 
+--- pine4.59.9z/pine/pine.h
++++ pine4.59.9d/pine/pine.h
+@@ -178,7 +179,6 @@
+ #define GER_ALLPARTS          0x04    /* AllParts toggle is on            */
+ 
+ #define GFHP_STRIPPED         0x01
+-#define GFHP_HANDLES          0x02
+ #define GFHP_LOCAL_HANDLES    0x04
+ 
+ #define       GFW_HANDLES             0x01

================================================================
Index: SOURCES/pine-utf8-1a-pine.h.patch
diff -u /dev/null SOURCES/pine-utf8-1a-pine.h.patch:1.1
--- /dev/null   Thu Mar 29 16:50:45 2007
+++ SOURCES/pine-utf8-1a-pine.h.patch   Thu Mar 29 16:50:40 2007
@@ -0,0 +1,68 @@
+Changelog:
+
+   * unused GFHP_NOWRAP removed,
+   * GFHP_HANDLES was moved to bk-cleanup-GFHP_HANDLES.patch
+ 
+--- pine4.64/pine/pine.h
++++ pine4.64/pine/pine.h
+@@ -68,6 +68,7 @@
+ #define       PHONE_HOME_HOST         "docserver.cac.washington.edu"
+ 
+ #define UNKNOWN_CHARSET               "X-UNKNOWN"
++#define US_ASCII_CHARSET      "US-ASCII"
+ 
+ #define OUR_HDRS_LIST         "X-Our-Headers"
+ 
+@@ -3675,6 +3676,7 @@
+     } data;
+ } REPLY_S;
+ 
++#define pico(F) call_pico(F)
+ #define       REPLY_PSEUDO    1
+ #define       REPLY_FORW      2       /* very similar to REPLY_PSEUDO */
+ #define       REPLY_MSGNO     3
+@@ -4231,7 +4233,6 @@
+ } ATABLE_S;
+ 
+ 
+-#define TAG_EMBED     '\377'  /* Announces embedded data in text string */
+ #define       TAG_INVON       '\001'  /* Supported character attributes       
  */
+ #define       TAG_INVOFF      '\002'
+ #define       TAG_BOLDON      '\003'
+@@ -4241,6 +4242,7 @@
+ #define       TAG_FGCOLOR     '\010'  /* Change to this foreground color      
  */
+ #define       TAG_BGCOLOR     '\011'  /* Change to this background color      
  */
+ #define       TAG_HANDLE      '\020'  /* indicate's a handle to an action     
  */
++#define       TAG_EMBED       '\021'  /* Announces embedded data in text 
string */
+ #define       TAG_HANDLEOFF   '\030'  /* indicate's end of handle text        
  */
+ 
+ 
+@@ -5735,6 +5737,9 @@
+ int       rfc2369_parse_fields PROTO((char *, RFC2369_S *));
+ unsigned char *trans_euc_to_2022_jp PROTO((unsigned char *));
+ unsigned char *trans_2022_jp_to_euc PROTO((unsigned char *, unsigned int *));
++unsigned char* resolve_charset_alias PROTO((char *, char **));
++char          *pine_check_utf8 PROTO((char *, char *, size_t));
++unsigned char *trans_with_iconv PROTO((unsigned char *, char *, char *));
+ char       *keyword_to_nick PROTO((char *));
+ void        find_8bitsubj_in_messages PROTO((MAILSTREAM *, SEARCHSET *,
+                                            int, int));
+--- pine4.64/pine/send.c
++++ pine4.64/pine/send.c
+@@ -11119,3 +11119,16 @@
+ {
+     return(0L);
+ }
++
++int
++call_pico (ps)
++      struct pico_struct * ps;
++{
++      int ret;
++      char * assumed_save = ps_global->VAR_ASSUMED_CHAR_SET;
++      ps_global->VAR_ASSUMED_CHAR_SET = NULL;
++#undef pico
++      ret = pico(ps);
++      ps_global->VAR_ASSUMED_CHAR_SET = assumed_save;
++      return ret;
++}

================================================================
Index: SOURCES/pine-utf8-1b.patch
diff -u /dev/null SOURCES/pine-utf8-1b.patch:1.1
--- /dev/null   Thu Mar 29 16:50:45 2007
+++ SOURCES/pine-utf8-1b.patch  Thu Mar 29 16:50:40 2007
@@ -0,0 +1,687 @@
+Submission of this patch with documentation:
+================================================================================
+--- pine4.64/pico/composer.c
++++ pine4.64/pico/composer.c
+@@ -344,7 +344,189 @@
+       return(TRUE);
+ }
+ 
++/*
++ * check_utf8 - check for UTF-8 bytes 
++ * Takes two arguments:
++ *   char *c          - a byte of the stream
++ *   char *utf_seq    - a status array holding the function's state
++ * utf_seq must be provided by the caller this way:
++ *  (static) char utf_seq[7] = ""; (content must be retained over calls)
++ *  and must be initialized at start using: utf_seq[0] = 0;
++ *
++ * Returns NULL if an UTF-8 sequence has been started and is not completed.
++ * If an UTF-8 sequence is complete, it returns a pointer to a static string
++ * which is valid until the next use of the function.
++ * If the character is a double width character, a space(' ') is prepended
++ * to the returned string.
++ * If a character < 128 is passed, the UTF-8 state in utf_seq[] is cleared,
++ * because a valid UTF-8 sequence only consists of bytes >= 0x80. The pointer
++ * returned points to the address of the passed character to indicate this.
++ * Features: Supports UTF-8 seqencies up to 4 bytes.
++ * Todo: Instead of passing a pointer to the char and comparing the returned
++ *       pointer to this address afterwards, the Interface could be changed
++ *       to just pass the character as simple char(thus not requesting the
++ *       address of a variable which might be declared as register) and 
replace
++ *       the check of the return value with a check of (c & 0x80) and if this
++ *       is not the case, assuming that (utf_seq[0] == 0) means that this last
++ *       non-ASCII byte completed the UTF-8 sequence, while having
++ *       utf_seq[0] != 0 means having an incomplete UTF-8 sequence.
++ */
++char *
++check_utf8(c, utf_seq, sizeof_utf_seq)
++     char *c;
++     char *utf_seq;
++     size_t sizeof_utf_seq;
++{
++    static   char char_string[8]; /* (six UTF-8 sequence bytes + ' ' + '\0') 
*/
++    int      ix;
++    unsigned char dbl_wide[7][2][4] = {0xe1,0x84,0x80,0x00, 
0xe1,0x85,0x9F,0x00,
++                                     0xe2,0x8c,0xa9,0x00, 0xe2,0x8c,0xaa,0x00,
++                                     0xe2,0xba,0x80,0x00, 0xed,0x9e,0xa3,0x00,
++                                     0xef,0xa4,0x80,0x00, 0xef,0xa9,0xaa,0x00,
++                                     0xef,0xb8,0xb0,0x00, 0xef,0xb9,0xa8,0x00,
++                                     0xef,0xbc,0x81,0x00, 0xef,0xbd,0xad,0x00,
++                                     0xef,0xbf,0xa0,0x00, 
0xef,0xbf,0xa6,0x00};
++    if (*c & 0x80) {
++       char_string[0] = *c;
++       char_string[1] = 0;
++       if (strlen(utf_seq) == sizeof_utf_seq - 1)
++        utf_seq[0] = 0;          /* don't allow a overlong UTF-8 sequence   */
++       if ((*c & 0xF0) >= 0xC0) {
++        strncpy(utf_seq, char_string, sizeof_utf_seq);
++        return NULL;             /* possible UTF-8 sequence, need next byte */
++       } else if (utf_seq[0]) {
++        strncat(utf_seq, char_string, sizeof_utf_seq); /* append to string */
++        switch (utf_seq[0] & 0xF0) {
++           case 0xC0 :
++           case 0xD0 :
++               strncpy(char_string, utf_seq, sizeof(char_string));
++               utf_seq[0] = 0;         /* sequence complete, clear for next */
++               return char_string;     /* pass the new UTF-8 sequence on    */
++           case 0xE0 :
++               if (strlen(utf_seq) < 3)
++                  return NULL; // 3-byte UTF-8, need next byte
++               char_string[0] = '\0'; // init
++               for (ix = 0; ix < 7; ix++)
++                     if (strcmp(utf_seq, &dbl_wide[ix][0][0]) >= 0
++                      && strcmp(utf_seq, &dbl_wide[ix][1][0]) <= 0) {
++                        char_string[0] = ' ';  /* flag as double-width char */
++                        break;
++               }
++               strncat(char_string, utf_seq, sizeof(char_string));
++               utf_seq[0] = 0; // this sequence is over, clear for restart
++               return char_string; // process this UTF-8 char...
++           case 0xF0 :
++               if (strlen(utf_seq) < 4)
++                  return NULL;     /* 4-byte UTF-8 sequence, need next byte */
++               char_string[0] = '\0';            /* init the sequence space */
++               if ((utf_seq[1] & 0xF0) == 0xA0)
++                  char_string[0] = ' ';  /* flag as double-width UTF-8 char */
++               strncat(char_string, utf_seq, sizeof(char_string));
++               utf_seq[0] = 0;         /* sequence complete, clear for next */
++               return char_string;     /* pass the new UTF-8 sequence on    */
++        }
++       }
++    }
++    utf_seq[0] = 0;  /* clear sequence buffer in case of an invalid sequence 
*/
++    return c;        /* single-byte, NON-UTF-8 chars are process it as usual 
*/
++}
++
++/*
++ * wrapper to check_utf8 for pico, if not in UTF-8 mode, do not check UTF-8
++ */
++char *
++pico_check_utf8(c, utf_seq, sizeof_utf_seq)
++     char *c;
++     char *utf_seq;
++     size_t sizeof_utf_seq;
++{
++    if(!(Pmaster->pine_flags & P_UNICODE))
++      return c;
++    return check_utf8(c, utf_seq, sizeof_utf_seq);
++}
++
++/*
++ * Get the number of columns which are filled by the text in the current
++ * line of LineEdit(from the start of the line to the current position)
++ */
++static int
++count_screencols(void)
++{
++      char utf_seq[7] = "", *cp, *r;
++      int seq = 0, w = 0;
++
++      for(cp = ods.cur_l->text; *cp && cp < ods.cur_l->text + ods.p_off;
++                      cp++) {
++              if (!(r = pico_check_utf8(cp, utf_seq, sizeof(utf_seq)))) {
++                      seq = 1;
++                      continue;
++              }
++              if (seq)
++                      w++;
++              seq = 0;
++              if (r == cp)
++                      w++;
++              else if (*r == ' ')
++                      w++;
++      }
++      return w;
++}
+ 
++/*
++ * Get the offset in screen positions which must be subsctracted from the
++ * byte count in the LineEdit line in order to reach the line position on
++ * screen(because of double wide characters and multible UTF-8 bytes)
++ */
++static int
++offset_on_screen(void)
++{
++      return ods.p_off - count_screencols();
++}
++
++/*
++ * Move current position in LineEdit one character left, return the number
++ * of byte positons which were neccesary to jump left in order to
++ * arrive at the start of the previous multibyte character(UTF-8).
++ */
++static int
++LineEditCharLeft()
++{
++    int col_right = ods.p_off, cols = count_screencols();
++
++    do
++      if (--ods.p_off < 0)
++              break;
++    while (count_screencols() - cols == -1);
++
++    ods.p_off++;
++      
++    if (col_right - ods.p_off > 0)
++      return col_right - ods.p_off;
++
++    do
++      if (--ods.p_off < 0)
++              break;
++    while (count_screencols() - cols == -2);
++
++    ods.p_off++;
++      
++    return col_right - ods.p_off;
++}
++
++/*
++ * Move current position in LineEdit one character right, if UTF-8
++ * mode is active, the ods.p_off is assumed to be at the start of
++ * a UTF-8 sequence or at a normal ASCII character. It is moved to
++ * the next character, jumping past the end of the current UTF-8
++ * sequence, if UTF8 mode is active.
++ */
++static void
++LineEditCharRight()
++{
++    char utf_seq[7] = "";
++    while(ods.p_off < ods.p_len && ods.cur_l->text[ods.p_off] &&
++      !pico_check_utf8(ods.cur_l->text + ods.p_off++, utf_seq, 
sizeof(utf_seq)));
++}
+ 
+ /*
+  *  ResizeHeader - Handle resizing display when SIGWINCH received.
+@@ -397,7 +579,7 @@
+     PaintBody(0);
+ 
+     if(ComposerEditing)
+-      movecursor(ods.p_line, ods.p_off+headents[ods.cur_e].prlen);
++      HeaderPaintCursor();
+ 
+     (*term.t_flush)();
+     return(TRUE);
+@@ -1596,6 +1778,7 @@
+            int        skipmove = 0;
+              char     *strng;
+     int      last_key;                                /* last keystroke  */
++    unsigned char     utf_seq[7] = "";
+ 
+     strng   = ods.cur_l->text;                        /* initialize offsets */
+     ods.p_len = strlen(strng);
+@@ -1678,7 +1861,7 @@
+           }
+ 
+           clearcursor();
+-          movecursor(ods.p_line, ods.p_off+headents[ods.cur_e].prlen);
++          HeaderPaintCursor();
+           if(ch == NODATA)                    /* GetKey timed out */
+             continue;
+ 
+@@ -1688,7 +1871,7 @@
+         if(mpresf){                           /* blast old messages */
+           if(mpresf++ > NMMESSDELAY){         /* every few keystrokes */
+               mlerase();
+-              movecursor(ods.p_line, ods.p_off+headents[ods.cur_e].prlen);
++              HeaderPaintCursor();
+           }
+         }
+ 
+@@ -1734,12 +1917,40 @@
+ 
+               /*
+                * then find out where things fit...
++               *
++               * For UTF-8, the < LINELEN check should need to do it's
++               * calculation based on count_screencols() plus the width
++               * of the new char as provided by pico_check_utf8.
++               * The buffer size may need to be increased for this.
+                */
+               if(ods.p_len < LINELEN()){
+                   CELL c;
++                  char tmp;
+ 
+-                  c.c = ch;
+                   c.a = 0;
++                  if(Pmaster->pine_flags & P_UNICODE) {
++                      tmp = ch;
++                      char * chp = pico_check_utf8(&tmp, utf_seq, 
sizeof(utf_seq));
++                      if (chp == NULL)
++                          continue;           /* on to the next! */
++                      if (chp != &tmp && *chp == ' ')
++                          chp++;
++                      if (*chp & 0x80) {
++                          while (*chp && ods.p_len < LINELEN()) {
++                              c.c = *chp++;
++                              pinsert(c);     /* add char to str */
++                          }
++                          /* update the display: */
++                          PaintHeader(COMPOSER_TOP_LINE, TRUE);
++                          /* If end char was inserted, set physical .. */
++                          if (ods.p_off == ods.p_len)
++                              /* cursor pos on next movecursor_offset: */
++                              movecursor_offset(-1, 0, 0);
++                          continue;           /* on to the next! */
++                      }
++                  }
++
++                  c.c = ch;
+                   if(pinsert(c)){             /* add char to str */
+                       skipmove++;             /* must'a been optimal */
+                       continue;               /* on to the next! */
+@@ -1776,6 +1987,7 @@
+             } 
+         }
+         else {                                        /* interpret ch as a 
command */
++          utf_seq[0] = '\0';
+             switch (ch = normalize_cmd(ch, ckm, 2)) {
+             case (CTRL|'\\') :
+               if (ch = GetAccent())
+@@ -1869,9 +1869,7 @@
+             case KEY_RIGHT:                   /* move character right */
+               if(ods.p_off < ods.p_len 
+                  && ods.p_off + headents[ods.cur_e].prlen < term.t_ncol){
+-                  pputc(pscr(ods.p_line, 
+-                             (ods.p_off++)+headents[ods.cur_e].prlen)->c,0);
+-                  skipmove++;
++                  LineEditCharRight();
+                   continue;
+               }
+               else if(gmode & MDHDRONLY)
+@@ -1882,7 +2092,7 @@
+             case (CTRL|'B') :
+             case KEY_LEFT     :               /* move character left */
+               if(ods.p_off > 0){
+-                  ods.p_off--;
++                  LineEditCharLeft();
+                   continue;
+               }
+               if(ods.p_line != COMPOSER_TOP_LINE)
+@@ -1917,7 +2127,8 @@
+                   continue;
+               }
+ 
+-              pputc(strng[ods.p_off++], 0);   /* drop through and rubout */
++              LineEditCharRight(); /* jump to next char */
++              /* and fall thru */
+ 
+             case DEL        :                 /* blast previous char */
+             case (CTRL|'H') :
+@@ -1931,20 +2142,27 @@
+                   continue;
+               }
+ 
+-              if(ods.p_off > 0){              /* just shift left one char */
+-                  ods.p_len--;
++              if(ods.p_off > 0){              /* shift left one char */
++                  int todelete = LineEditCharLeft();
++
++                  ods.p_len -= todelete;
++
+                   headents[ods.cur_e].dirty  = 1;
+                   if(ods.p_len == 0)
+                     headents[ods.cur_e].sticky = 0;
+                   else
+                     headents[ods.cur_e].sticky = 1;
+ 
+-                  tbufp = &strng[--ods.p_off];
+-                  while(*tbufp++ != '\0')
+-                    tbufp[-1] = *tbufp;
+                   tbufp = &strng[ods.p_off];
++
++                  while(*tbufp++ != '\0')
++                    tbufp[-1] = tbufp[todelete-1];
++
+                   if(pdel())                  /* physical screen delete */
+                     skipmove++;               /* must'a been optimal */
++
++                  /* needed if pine bgcolor != terminal background color */
++                  PaintHeader(ods.p_line, TRUE);
+               }
+               else{                           /* may have work to do */
+                   if(ods.cur_l->prev == NULL){  
+@@ -1955,18 +2173,16 @@
+                   ods.p_line--;
+                   ods.cur_l = ods.cur_l->prev;
+                   strng = ods.cur_l->text;
+-                  if((i=strlen(strng)) > 0){
+-                      strng[i-1] = '\0';      /* erase the character */
+-                      ods.p_off = i-1;
++                  if((ods.p_off=strlen(strng)) > 0){
++                      ods.p_off -= LineEditCharLeft() - 1;
++                      strng[ods.p_off] = '\0'; /* erase the character */
+                   }
+-                  else{
++                  else
+                       headents[ods.cur_e].sticky = 0;
+-                      ods.p_off = 0;
+-                  }
+-                  
+-                  tbufp = &strng[ods.p_off];
+               }
+ 
++              tbufp = &strng[ods.p_off];
++
+               if((status = FormatLines(ods.cur_l, "", LINELEN(), 
+                                  headents[ods.cur_e].break_on_comma,0))==-1){
+                   (*term.t_beep)();
+@@ -1991,7 +2207,7 @@
+                     PaintBody(1);
+               }
+ 
+-              movecursor(ods.p_line, ods.p_off+headents[ods.cur_e].prlen);
++              HeaderPaintCursor();
+ 
+               if(skipmove)
+                 continue;
+@@ -2016,7 +2232,8 @@
+ void
+ HeaderPaintCursor()
+ {
+-    movecursor(ods.p_line, ods.p_off+headents[ods.cur_e].prlen);
++    movecursor_offset(ods.p_line, ods.p_off + headents[ods.cur_e].prlen,
++              offset_on_screen());
+ }
+ 
+ 
+--- pine4.64/pico/display.c
++++ pine4.64/pico/display.c
+@@ -1295,7 +1295,22 @@
+     }
+ }
+ 
++void
++movecursor_offset(row, col, offs)
++int row, col, offs;
++{
++    static int force_next = 0;
+ 
++    if(row == -1) {
++      force_next = row;
++      return;
++    }
++    if(row!=ttrow || col!=ttcol || force_next) {
++        (*term.t_move)(row, col - offs);
++        ttrow = row;
++        ttcol = col;
++    }
++}
+ 
+ /*
+  * Send a command to the terminal to move the hardware cursor to row "row"
+--- pine4.64/pico/efunc.h
++++ pine4.64/pico/efunc.h
+@@ -118,6 +118,7 @@
+ extern        VARS_TO_SAVE *save_pico_state PROTO((void));
+ extern        void restore_pico_state PROTO((VARS_TO_SAVE *));
+ extern        void free_pico_state PROTO((VARS_TO_SAVE *));
++extern  char *check_utf8 PROTO((char *, char *, size_t));
+ extern        void HeaderPaintCursor PROTO((void));
+ extern        void PaintBody PROTO((int));
+ 
+--- pine4.64/pine/osdep/termout.unx
++++ pine4.64/pine/osdep/termout.unx
+@@ -750,7 +750,8 @@
+      register unsigned int ch;
+      int      new_esc_len;
+ {
+-    static   int esc_len = 0;
++    static   int esc_len = 0, seq = 0;
++    static   unsigned char utf_seq[7] = "";
+ 
+     if(ps_global->in_init_seq                         /* silent */
+        || (F_ON(F_BLANK_KEYMENU, ps_global)           /* or bottom, */
+@@ -759,6 +768,35 @@
+          && _col + 1 == ps_global->ttyo->screen_cols))
+       return;
+ 
++    /* Treat UTF-8 sequences if we are not in a special escape sequence */
++    if(esc_len <= 0) {
++      unsigned char *chp;
++      char tmp;
++      tmp = (char)ch;
++      if ((chp = pine_check_utf8(&tmp, utf_seq, sizeof(utf_seq))) == NULL) {
++          seq = 1; /* flag that we are in a open UTF-8 sequence   */
++          return;  /* UTF-8 sequence not complete, need next char */
++      }
++      if (chp != (unsigned char*)&tmp) {
++          seq = 0; /* flag that we are not in a open UTF-8 sequence */
++          _col++;
++          if (*chp == ' ') {
++              if(++_col > ps_global->ttyo->screen_cols) {
++                  printf("\342\200\246"); /* UTF-8 points... */
++                  goto wrap;
++              }
++              chp++;
++          }
++          while(*chp)
++              putchar(*chp++);
++          return;
++      }
<<Diff was trimmed, longer than 597 lines>>
_______________________________________________
pld-cvs-commit mailing list
[email protected]
http://lists.pld-linux.org/mailman/listinfo/pld-cvs-commit

Reply via email to