[no subject]

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


-- 
Lyrian 
------=_NextPart_000_0117_01C0DA01.68633B10
Content-Type: application/octet-stream;
	name="nolimit.diff"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="nolimit.diff"

No more chance to write after the end of a buffer=0A=
=0A=
To apply the patch:=0A=
cd allegro=0A=
patch -p1 < nolimit.diff=0A=
=0A=
--- allegro_original/docs/allegro._tx	Thu May 10 09:11:54 2001=0A=
+++ allegro/docs/allegro._tx	Sat May  5 10:00:31 2001=0A=
@@ -6799,7 +6799,7 @@=0A=
    Like alert(), but with three buttons. Returns 1, 2, or 3.=0A=
 =0A=
 @@int @file_select(const char *message, char *path, const char *ext);=0A=
-@domain.hid file_select_ex, gui_fg_color=0A=
+@xref file_select_ex, file_select_ex_ex, gui_fg_color=0A=
    Displays the Allegro file selector, with the message as caption. The =
path =0A=
    parameter contains the initial filename to display (this can be used =
to =0A=
    set the starting directory, or to provide a default filename for a =0A=
@@ -6816,15 +6816,22 @@=0A=
    (directory), and 'a' (archive). For example, an extension string of =0A=
    "PCX;BMP;/+r-d" will display only PCX or BMP files that are =
read-only, =0A=
    but not directories. Returns zero if it was closed with the Cancel =0A=
-   button, non-zero if it was OK'd.=0A=
+   button, non-zero if it was OK'd. It will also return non-zero if the =
path=0A=
+   was truncated, with the truncated path in the path parameter.=0A=
 =0A=
 @\int @file_select_ex(const char *message, char *path, const char *ext,=0A=
 @@                    int w, int h);=0A=
-@domain.hid file_select, gui_fg_color=0A=
+@xref file_select, file_select_ex_ex, gui_fg_color=0A=
    Does the same as file_select(), but stretches the dialog to the =
width and=0A=
    height specified and to the font size. If either size argument is =
set to=0A=
    zero, the function stretches the selector to the corresponding =
screen =0A=
    dimension.=0A=
+=0A=
+@\int @file_select_ex_ex(const char *message, char *path, const char =
*ext,=0A=
+@@                       int size, int w, int h);=0A=
+@xref file_select, file_select_ex_ex, gui_fg_color=0A=
+   Does the same as file_select_ex(), but allows to specify the length =
(in=0A=
+   bytes) of the path parameter.=0A=
 =0A=
 @@int @gfx_mode_select(int *card, int *w, int *h);=0A=
 @xref gfx_mode_select_ex, set_gfx_mode, gui_fg_color=0A=
--- allegro_original/include/allegro.h	Thu May 10 09:11:55 2001=0A=
+++ allegro/include/allegro.h	Mon May  7 19:19:21 2001=0A=
@@ -2203,6 +2203,7 @@=0A=
 AL_FUNC(int, alert3, (AL_CONST char *s1, AL_CONST char *s2, AL_CONST =
char *s3, AL_CONST char *b1, AL_CONST char *b2, AL_CONST char *b3, int =
c1, int c2, int c3));=0A=
 AL_FUNC(int, file_select, (AL_CONST char *message, char *path, AL_CONST =
char *ext));=0A=
 AL_FUNC(int, file_select_ex, (AL_CONST char *message, char *path, =
AL_CONST char *ext, int w, int h));=0A=
+AL_FUNC(int, file_select_ex_ex, (AL_CONST char *message, char *path, =
AL_CONST char *ext, int size, int w, int h));=0A=
 AL_FUNC(int, gfx_mode_select, (int *card, int *w, int *h));=0A=
 AL_FUNC(int, gfx_mode_select_ex, (int *card, int *w, int *h, int =
*color_depth));=0A=
 =0A=
--- allegro_original/src/text.c	Thu May 10 09:11:58 2001=0A=
+++ allegro/src/text.c	Wed May  2 13:10:50 2001=0A=
@@ -97,7 +97,7 @@=0A=
 {=0A=
    char toks[32];=0A=
    char *tok[128];=0A=
-   char strbuf[512];=0A=
+   char *strbuf=3DNULL;=0A=
    int i, minlen, last, space;=0A=
    float fleft, finc;=0A=
 =0A=
@@ -109,10 +109,15 @@=0A=
 =0A=
    /* count words and measure min length (without spaces) */ =0A=
    minlen =3D 0;=0A=
-   ustrcpy(strbuf, str);=0A=
+   strbuf =3D ustrdup(str);=0A=
+   if(!strbuf) {=0A=
+      /* Can't justify ! */=0A=
+      textout(bmp, f, str, x1, y, color);=0A=
+      return;=0A=
+   }=0A=
    last =3D 0;=0A=
 =0A=
-   for (tok[last] =3D ustrtok(strbuf, toks); tok[last]; tok[last] =3D =
ustrtok(NULL, toks)) {=0A=
+   for (tok[last] =3D ustrtok(strbuf, toks); tok[last] && =
last<sizeof(tok)/sizeof(char*); tok[last] =3D ustrtok(NULL, toks)) {=0A=
       minlen +=3D text_length(f, tok[last]);=0A=
       last++; =0A=
    }=0A=
@@ -123,6 +128,7 @@=0A=
    if ((space <=3D 0) || (space > diff) || (last < 2)) {=0A=
       /* can't justify */=0A=
       textout(bmp, f, str, x1, y, color);=0A=
+      free(strbuf);=0A=
       return; =0A=
    }=0A=
 =0A=
@@ -133,6 +139,7 @@=0A=
       textout(bmp, f, tok[i], (int)fleft, y, color);=0A=
       fleft +=3D (float)text_length(f, tok[i]) + finc;=0A=
    }=0A=
+   free(strbuf);=0A=
 }=0A=
 =0A=
 =0A=
--- allegro_original/src/gui.c	Thu May 10 09:11:57 2001=0A=
+++ allegro/src/gui.c	Fri May  4 16:50:38 2001=0A=
@@ -1128,8 +1128,8 @@=0A=
 static void draw_menu_item(MENU_INFO *m, int c)=0A=
 {=0A=
    int fg, bg;=0A=
-   int i, j, x, y, w;=0A=
-   char buf[256], *tok;=0A=
+   int x, y, w;=0A=
+   char *buf, *tok;=0A=
    int my;=0A=
    int rtm;=0A=
 =0A=
@@ -1160,20 +1160,13 @@=0A=
    rtm =3D text_mode(bg);=0A=
 =0A=
    if (ugetc(m->menu[c].text)) {=0A=
-      i =3D 0;=0A=
-      j =3D ugetc(m->menu[c].text);=0A=
-=0A=
-      while ((j) && (j !=3D '\t')) {=0A=
-	 i +=3D usetc(buf+i, j);=0A=
-	 j =3D ugetc(m->menu[c].text+i);=0A=
-      }=0A=
+      buf =3D ustrdup(m->menu[c].text);=0A=
+      tok =3D ustrtok(buf, uconvert_ascii("\t", NULL));=0A=
 =0A=
-      usetc(buf+i, 0);=0A=
+      gui_textout(screen, tok, x+8, y+1, fg, FALSE);=0A=
 =0A=
-      gui_textout(screen, buf, x+8, y+1, fg, FALSE);=0A=
-=0A=
-      if (j =3D=3D '\t') {=0A=
-	 tok =3D m->menu[c].text+i + uwidth(m->menu[c].text+i);=0A=
+      tok =3D ustrtok(NULL, uconvert_ascii("", NULL));=0A=
+      if(tok) {=0A=
 	 gui_textout(screen, tok, x+w-gui_strlen(tok)-10, y+1, fg, FALSE);=0A=
       }=0A=
 =0A=
@@ -1189,7 +1182,8 @@=0A=
          hline(screen, x+w-8, my+4, x+w-7, fg);=0A=
          putpixel(screen, x+w-8, my+5, fg);=0A=
       }=0A=
-      =0A=
+=0A=
+      free(buf);=0A=
    }=0A=
    else=0A=
       hline(screen, x, y+text_height(font)/2+2, x+w, fg);=0A=
@@ -1266,9 +1260,9 @@=0A=
  */=0A=
 static void fill_menu_info(MENU_INFO *m, MENU *menu, MENU_INFO *parent, =
int bar, int x, int y, int minw, int minh)=0A=
 {=0A=
-   char buf[80], *tok;=0A=
+   char *buf, *tok;=0A=
    int extra =3D 0;=0A=
-   int c, i, j;=0A=
+   int c;=0A=
    int child =3D FALSE;=0A=
 =0A=
    m->menu =3D menu;=0A=
@@ -1286,17 +1280,16 @@=0A=
 =0A=
       if ((m->menu[m->size].child) && (!m->bar)) child =3D TRUE;=0A=
 =0A=
-      i =3D 0;=0A=
-      j =3D ugetc(m->menu[m->size].text);=0A=
+      if (ugetc(m->menu[m->size].text)) {=0A=
+         buf =3D ustrdup(m->menu[m->size].text);=0A=
+         tok =3D ustrtok(buf, uconvert_ascii("\t", NULL));=0A=
 =0A=
-      while ((j) && (j !=3D '\t')) {=0A=
-	 i +=3D usetc(buf+i, j);=0A=
-	 j =3D ugetc(m->menu[m->size].text+i);=0A=
+         c =3D gui_strlen(tok);=0A=
+      }=0A=
+      else {=0A=
+         buf =3D 0;=0A=
+         c =3D 0;=0A=
       }=0A=
-=0A=
-      usetc(buf+i, 0);=0A=
-=0A=
-      c =3D gui_strlen(buf);=0A=
 =0A=
       if (m->bar) {=0A=
 	 m->w +=3D c+16;=0A=
@@ -1306,10 +1299,13 @@=0A=
 	 m->w =3D MAX(m->w, c+16);=0A=
       }=0A=
 =0A=
-      if (j =3D=3D '\t') {=0A=
-	 tok =3D m->menu[m->size].text+i + uwidth(m->menu[m->size].text+i);=0A=
-	 c =3D gui_strlen(tok);=0A=
-	 extra =3D MAX(extra, c);=0A=
+      if (buf) {=0A=
+         tok =3D ustrtok(NULL, uconvert_ascii("", NULL));=0A=
+         if(tok) {=0A=
+	    c =3D gui_strlen(tok);=0A=
+	    extra =3D MAX(extra, c);=0A=
+         }=0A=
+         free(buf);=0A=
       }=0A=
    }=0A=
 =0A=
--- allegro_original/src/fsel.c	Thu May 10 09:11:57 2001=0A=
+++ allegro/src/fsel.c	Sat May  5 09:53:32 2001=0A=
@@ -308,32 +308,47 @@=0A=
 static int fs_edit_proc(int msg, DIALOG *d, int c)=0A=
 {=0A=
    char *s =3D d->dp;=0A=
+   int size =3D d->d1; /* Lengt in characters */=0A=
+   int raw_size =3D uwidth_max(get_uformat()) * size; /* Length in =
bytes */=0A=
    int list_size;=0A=
    int found =3D 0;=0A=
-   char b[512];=0A=
+   char *b;=0A=
    int ch, attr;=0A=
    int i;=0A=
 =0A=
    if (msg =3D=3D MSG_START) {=0A=
-      fix_filename_path(b, s, sizeof(b));=0A=
-      ustrcpy(s, b);=0A=
+      b =3D malloc(sizeof(char) * (raw_size+ucwidth(0)));=0A=
+      fix_filename_path(b, s, size); /* Uses the length in characters */=0A=
+      ustrncpy(s, b, raw_size); /* Uses the length in bytes */=0A=
+      free(b);=0A=
    }=0A=
 =0A=
    if (msg =3D=3D MSG_KEY) {=0A=
       if ((!ugetc(s)) || (ugetat(s, -1) =3D=3D DEVICE_SEPARATOR))=0A=
-	 ustrcat(s, uconvert_ascii("./", NULL));=0A=
+	 ustrncat(s, uconvert_ascii("./", NULL), raw_size); /* Uses the length =
in bytes */=0A=
 =0A=
-      fix_filename_path(b, s, sizeof(b));=0A=
-      ustrcpy(s, b);=0A=
+      b =3D malloc(sizeof(char) * (raw_size+ucwidth(0)));=0A=
+      fix_filename_path(b, s, raw_size); /* Uses the length in bytes */=0A=
+      ustrncpy(s, b, raw_size); /* Uses the length in bytes */=0A=
+      free(b);=0A=
+      /* Here s (i.e. the path) may have been trucated */=0A=
 =0A=
       ch =3D ugetat(s, -1);=0A=
       if ((ch !=3D '/') && (ch !=3D OTHER_PATH_SEPARATOR)) {=0A=
+         /* If the file exists */=0A=
 	 if (file_exists(s, FA_RDONLY | FA_HIDDEN | FA_DIREC, &attr)) {=0A=
-	    if (attr & FA_DIREC)=0A=
-	       put_backslash(s);=0A=
+            /* And it is a directory, don't close */=0A=
+	    if (attr & FA_DIREC) {=0A=
+               /* Make sure there is enough place */=0A=
+               if(ustrsizez(s) < raw_size-uwidth_max(get_uformat())) {=0A=
+	          put_backslash(s);=0A=
+               }=0A=
+            }=0A=
+            /* And it is not a directory, close */=0A=
 	    else=0A=
 	       return D_CLOSE;=0A=
 	 }=0A=
+         /* If the file doesn't exists (or has been truncated!), close =
*/=0A=
 	 else=0A=
 	    return D_CLOSE;=0A=
       }=0A=
@@ -609,6 +624,8 @@=0A=
 {=0A=
    static int recurse_flag =3D 0;=0A=
    char *s =3D file_selector[FS_EDIT].dp;=0A=
+   int size =3D file_selector[FS_EDIT].d1; /* Length in characters */=0A=
+   int raw_size =3D uwidth_max(get_uformat()) * size; /* Length in =
bytes */=0A=
    char tmp[32];=0A=
    int sel =3D d->d1;=0A=
    int i, ret;=0A=
@@ -658,7 +675,7 @@=0A=
    recurse_flag--;=0A=
 =0A=
    if (((sel !=3D d->d1) || (ret =3D=3D D_CLOSE)) && (recurse_flag =
=3D=3D 0)) {=0A=
-      replace_filename(s, flist->dir, flist->name[d->d1], 512);=0A=
+      replace_filename(s, flist->dir, flist->name[d->d1], raw_size); /* =
Uses the length in bytes */=0A=
       /* check if we want to `cd ..' */=0A=
       if ((!ustrncmp(flist->name[d->d1], "..", 2)) && (ret =3D=3D =
D_CLOSE)) {=0A=
 	 /* let's remember the previous directory */=0A=
@@ -826,21 +843,32 @@=0A=
 }=0A=
 =0A=
 =0A=
-int file_select_ex(AL_CONST char *message, char *path, AL_CONST char =
*ext, int width, int height)=0A=
+/* file_select_ex_ex:=0A=
+ *  See file_select comments.=0A=
+ *  Note: The size parameter is in bytes (not characters), while the =
file_select=0A=
+ *  function (theorically) needs a 80 characters (not bytes) buffer.=0A=
+ *  Note: because of the function fs_dlist_proc, size should not be =
less than=0A=
+ *  4*uwidth_max(get_uformat)=0A=
+ */=0A=
+int file_select_ex_ex(AL_CONST char *message, char *path, AL_CONST char =
*ext, int size, int width, int height)=0A=
 {=0A=
    char buf[512];=0A=
    int ret;=0A=
    char *p;=0A=
 =0A=
+   ASSERT(size>=3D4*uwidth_max(get_uformat()));=0A=
    ustrcpy(updir, empty_string);=0A=
    file_selector[FS_MESSAGE].dp =3D (char *)message;=0A=
+   file_selector[FS_EDIT].d1 =3D size/uwidth_max(get_uformat()) - 1;=0A=
    file_selector[FS_EDIT].dp =3D path;=0A=
    file_selector[FS_OK].dp =3D (void*)get_config_text("OK");=0A=
    file_selector[FS_CANCEL].dp =3D (void*)get_config_text("Cancel");=0A=
    fext =3D ext;=0A=
 =0A=
    if (!ugetc(path)) {=0A=
-      getcwd(buf, 80);=0A=
+      if(!getcwd(buf, MIN(size, sizeof(buf)))) {=0A=
+        buf[0]=3D0;=0A=
+      }=0A=
       do_uconvert(buf, U_ASCII, path, U_CURRENT, -1);=0A=
       fix_filename_case(path);=0A=
       fix_filename_slashes(path);=0A=
@@ -869,3 +897,7 @@=0A=
    return TRUE; =0A=
 }=0A=
 =0A=
+int file_select_ex(AL_CONST char *message, char *path, AL_CONST char =
*ext, int width, int height)=0A=
+{=0A=
+   return file_select_ex_ex(message, path, ext, =
80*uwidth_max(get_uformat()), width, height);=0A=
+}=0A=
--- allegro_original/setup/keyconf.c	Thu May 10 09:11:59 2001=0A=
+++ allegro/setup/keyconf.c	Fri May  4 17:07:27 2001=0A=
@@ -131,7 +131,12 @@=0A=
 =0A=
 char keyboard_name[64] =3D "";=0A=
 =0A=
-char config_file[256] =3D "";=0A=
+/* Length of the file_select buffer: 80 characters * maximum character=0A=
+ * width (6 bytes for UTF8)=0A=
+ */=0A=
+#define FILE_NAME_LENGTH (80*6)=0A=
+=0A=
+char config_file[FILE_NAME_LENGTH] =3D "";=0A=
 =0A=
 unsigned short *editor_table;=0A=
 =0A=
@@ -240,7 +245,7 @@=0A=
 /* handle the load command */=0A=
 int loader()=0A=
 {=0A=
-   char buf[256];=0A=
+   char buf[FILE_NAME_LENGTH];=0A=
 =0A=
    strcpy(buf, config_file);=0A=
 =0A=
@@ -319,7 +324,7 @@=0A=
 /* handle the save command */=0A=
 int saver()=0A=
 {=0A=
-   char buf[256];=0A=
+   char buf[FILE_NAME_LENGTH];=0A=
 =0A=
    strcpy(buf, config_file);=0A=
 =0A=
--- allegro_original/setup/setup.c	Thu May 10 09:11:59 2001=0A=
+++ allegro/setup/setup.c	Wed May  2 10:44:15 2001=0A=
@@ -1646,7 +1646,7 @@=0A=
 {=0A=
    PARAMETER *p =3D d->dp2;=0A=
    BITMAP *b;=0A=
-   char buf[256];=0A=
+   char buf[80*6]; /* 80 chars for file_select * max UTF8 char width */=0A=
    char buf2[256];=0A=
    int ret;=0A=
    int i;=0A=
--- allegro_original/tests/akaitest.c	Thu May 10 09:11:59 2001=0A=
+++ allegro/tests/akaitest.c	Wed May  2 10:45:26 2001=0A=
@@ -131,7 +131,7 @@=0A=
    int ret =3D d_button_proc(msg, d, c);=0A=
 =0A=
    if (ret & D_CLOSE) {=0A=
-      static char name[256] =3D "";=0A=
+      static char name[80*6] =3D ""; /* 80 chars for file_select * max =
UTF8 char width */=0A=
 =0A=
       if (file_select("Load Sample", name, "wav;voc")) {=0A=
 	 if (the_sample)=0A=
--- allegro_original/tests/digitest.c	Thu May 10 09:11:59 2001=0A=
+++ allegro/tests/digitest.c	Wed May  2 10:46:27 2001=0A=
@@ -23,7 +23,7 @@=0A=
 =0A=
 =0A=
 =0A=
-char samplename[256] =3D "";=0A=
+char samplename[80*6] =3D ""; /* 80 chars for file_select * max UTF8 =
char width */=0A=
 =0A=
 =0A=
 extern DIALOG thedialog[];=0A=
--- allegro_original/tests/test.c	Thu May 10 09:11:59 2001=0A=
+++ allegro/tests/test.c	Fri May  4 13:34:19 2001=0A=
@@ -3169,7 +3169,7 @@=0A=
 =0A=
    int old_mode =3D mode;=0A=
 =0A=
-   static char fname[256] =3D "";=0A=
+   static char fname[80*6] =3D ""; /* 80 chars for file_select * max =
UTF8 char width */=0A=
    FILE *f;=0A=
 =0A=
    int i;=0A=
@@ -3606,7 +3606,7 @@=0A=
    int old_3d =3D cpu_3dnow;=0A=
    BITMAP *old_screen =3D screen;=0A=
    BITMAP *buffer;=0A=
-   static char fname[256] =3D "";=0A=
+   static char fname[80*6] =3D ""; /* 80 chars for file_select * max =
UTF8 char width */=0A=
    FILE *f;=0A=
    int i;=0A=
 =0A=
--- allegro_original/tools/grabber.c	Thu May 10 09:11:59 2001=0A=
+++ allegro/tools/grabber.c	Wed May  9 17:29:28 2001=0A=
@@ -29,6 +29,9 @@=0A=
 #endif=0A=
 =0A=
 =0A=
+/* 80 chars for file_select * max UTF8 char width */=0A=
+#define FILE_NAME_LENGTH (80*6)=0A=
+=0A=
 =0A=
 typedef struct DATAITEM=0A=
 {=0A=
@@ -1650,7 +1653,7 @@=0A=
 /* handle the load command */=0A=
 static int loader()=0A=
 {=0A=
-   char buf[256];=0A=
+   char buf[FILE_NAME_LENGTH];=0A=
 =0A=
    CHECK_MENU_HOOK("Load", DATEDIT_MENU_FILE);=0A=
 =0A=
@@ -1670,7 +1673,7 @@=0A=
 /* handle the merge command */=0A=
 static int merger()=0A=
 {=0A=
-   char buf[256];=0A=
+   char buf[FILE_NAME_LENGTH];=0A=
 =0A=
    CHECK_MENU_HOOK("Merge", DATEDIT_MENU_FILE);=0A=
 =0A=
@@ -1690,7 +1693,7 @@=0A=
 /* do the actual work of saving a file */=0A=
 static int save(int strip)=0A=
 {=0A=
-   char buf[256], buf2[256];=0A=
+   char buf[FILE_NAME_LENGTH], buf2[256];=0A=
    int err =3D FALSE;=0A=
 =0A=
    strcpy(buf, data_file);=0A=
@@ -1968,7 +1971,7 @@=0A=
 static int reader()=0A=
 {=0A=
    DATAFILE *dat;=0A=
-   char buf[256], buf2[256];=0A=
+   char buf[FILE_NAME_LENGTH], buf2[256];=0A=
    AL_CONST char *s;=0A=
 =0A=
    CHECK_MENU_HOOK("Read", DATEDIT_MENU_FILE);=0A=
@@ -2066,7 +2069,7 @@=0A=
    DATAFILE *dat;=0A=
    char *desc =3D "binary data";=0A=
    AL_CONST char *ext =3D NULL;=0A=
-   char buf[256], name[256], type[8];=0A=
+   char buf[256], name[FILE_NAME_LENGTH], type[8];=0A=
    int sel;=0A=
    int i;=0A=
 =0A=
@@ -2131,7 +2134,7 @@=0A=
 {=0A=
    char *desc =3D "binary data";=0A=
    AL_CONST char *ext =3D NULL;=0A=
-   char buf[256], name[256];=0A=
+   char buf[256], name[FILE_NAME_LENGTH];=0A=
    DATAFILE *dat;=0A=
    int sel;=0A=
    int i;=0A=
--- allegro_original/tools/plugins/datalpha.c	Thu May 10 09:11:59 2001=0A=
+++ allegro/tools/plugins/datalpha.c	Wed May  2 10:51:19 2001=0A=
@@ -24,6 +24,9 @@=0A=
 #include "../datedit.h"=0A=
 =0A=
 =0A=
+/* 80 chars for file_select * max UTF8 char width */=0A=
+#define FILE_NAME_LENGTH (80*6)=0A=
+=0A=
 =0A=
 /* creates a monochrome image containing the alpha channel of this =
bitmap */=0A=
 static BITMAP *get_alpha_bitmap(BITMAP *bmp)=0A=
@@ -130,7 +133,7 @@=0A=
    DATAFILE tmpdat;=0A=
    RLE_SPRITE *rle;=0A=
    BITMAP *bmp;=0A=
-   char buf[256], name[256] =3D "";=0A=
+   char buf[256], name[FILE_NAME_LENGTH] =3D "";=0A=
    AL_CONST char *ext =3D NULL;=0A=
    int ret =3D 0;=0A=
 =0A=
@@ -251,7 +254,7 @@=0A=
 {=0A=
    BITMAP *newbmp;=0A=
    DATAFILE *alpha;=0A=
-   char buf[256], name[256];=0A=
+   char buf[256], name[FILE_NAME_LENGTH];=0A=
    AL_CONST char *ext =3D NULL;=0A=
    int x, y, c, r, g, b, a;=0A=
 =0A=
--- allegro_original/tools/plugins/datfont.c	Thu May 10 09:11:59 2001=0A=
+++ allegro/tools/plugins/datfont.c	Wed May  2 10:52:05 2001=0A=
@@ -1000,7 +1000,7 @@=0A=
 /* imports a new font range */=0A=
 static int import_proc(int msg, DIALOG *d, int c)=0A=
 {=0A=
-   char name[256];=0A=
+   char name[80*6]; /* 80 chars for file_select * max UTF8 char width */=0A=
    int ret =3D d_button_proc(msg, d, c);=0A=
    FONT *fnt, *f;=0A=
    long size;=0A=

------=_NextPart_000_0117_01C0DA01.68633B10
Content-Type: application/octet-stream;
	name="fbcon.diff"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="fbcon.diff"

Replace ustrcat by ustrncat=0A=
Don't use uninitialized buffers=0A=
=0A=
To apply the patch:=0A=
cd allegro=0A=
patch -p1 < fbcon.diff=0A=
=0A=
--- allegro_original/src/linux/fbcon.c	Thu May 10 09:11:57 2001=0A=
+++ allegro/src/linux/fbcon.c	Sat May  5 11:36:20 2001=0A=
@@ -110,7 +110,6 @@=0A=
  */=0A=
 static BITMAP *fb_init(int w, int h, int v_w, int v_h, int color_depth)=0A=
 {=0A=
-   char fname[256], tmp[256];=0A=
    AL_CONST char *p;=0A=
    int stride, tries, original_color_depth =3D _color_depth;=0A=
    BITMAP *b;=0A=
@@ -259,7 +258,7 @@=0A=
    if (fbaddr =3D=3D MAP_FAILED) {=0A=
       ioctl(fbfd, FBIOPUT_VSCREENINFO, &orig_mode);=0A=
       close(fbfd);=0A=
-      usprintf(allegro_error, get_config_text("Can't map framebuffer =
%s"), uconvert_ascii(fname, tmp));=0A=
+      usprintf(allegro_error, get_config_text("Can't map framebuffer"));=0A=
       return NULL;=0A=
    }=0A=
 =0A=
@@ -296,8 +295,8 @@=0A=
    do_uconvert(fix_info.id, U_ASCII, fb_desc, U_CURRENT, =
sizeof(fb_desc));=0A=
 =0A=
    if (fb_approx) {=0A=
-      ustrcat(fb_desc, uconvert_ascii(", ", NULL));=0A=
-      ustrcat(fb_desc, get_config_text("approx."));=0A=
+      ustrncat(fb_desc, uconvert_ascii(", ", NULL), sizeof(fb_desc));=0A=
+      ustrncat(fb_desc, get_config_text("approx."), sizeof(fb_desc));=0A=
    }=0A=
 =0A=
    gfx_fbcon.desc =3D fb_desc;=0A=
@@ -356,8 +355,8 @@=0A=
    if (!(vblank_flags & (FB_VBLANK_HAVE_VBLANK | FB_VBLANK_HAVE_STICKY =
| FB_VBLANK_HAVE_VCOUNT)))=0A=
  #endif=0A=
    {=0A=
-      ustrcat(fb_desc, uconvert_ascii(", ", NULL));=0A=
-      ustrcat(fb_desc, get_config_text("no vsync"));=0A=
+      ustrncat(fb_desc, uconvert_ascii(", ", NULL), sizeof(fb_desc));=0A=
+      ustrncat(fb_desc, get_config_text("no vsync"), sizeof(fb_desc));=0A=
    }=0A=
 =0A=
    /* is scrolling available? */=0A=

------=_NextPart_000_0117_01C0DA01.68633B10
Content-Type: application/octet-stream;
	name="ascii.diff"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="ascii.diff"

Do not give Unicode/UTF8 strings to 'open'=0A=
Test get_config_string return value=0A=
Convert usprintf param=0A=
=0A=
To apply the patch:=0A=
cd allegro=0A=
patch -p1 < ascii.diff=0A=
=0A=
--- allegro_original/src/linux/ljoy.c	Thu May 10 09:11:57 2001=0A=
+++ allegro/src/linux/ljoy.c	Fri May  4 09:51:01 2001=0A=
@@ -49,7 +49,7 @@=0A=
 	int i, s, a, b;=0A=
 =0A=
 	for (i =3D 0; i < MAX_JOYSTICKS; i++) {=0A=
-		usprintf (tmp, "/dev/js%d", i);=0A=
+		sprintf (tmp, "/dev/js%d", i);=0A=
 		joy_fd[i] =3D open (tmp, O_RDONLY);=0A=
 		if (joy_fd[i] =3D=3D -1) =0A=
 			break;=0A=
--- allegro_original/src/linux/lmseps2.c	Thu May 10 15:45:24 2001=0A=
+++ allegro/src/linux/lmseps2.c	Fri May  4 14:16:06 2001=0A=
@@ -166,9 +166,16 @@=0A=
 {=0A=
 	char tmp[80], tmp2[80], tmp3[80];=0A=
 	AL_CONST char *device;=0A=
+	AL_CONST char *udevice;=0A=
 =0A=
 	/* Find the device filename */=0A=
-	device =3D get_config_string (NULL, uconvert_ascii ("mouse_device", =
tmp), uconvert_ascii("/dev/mouse", tmp2));=0A=
+	udevice =3D get_config_string (NULL, uconvert_ascii ("mouse_device", =
tmp), uconvert_ascii("/dev/mouse", tmp2));=0A=
+	if(udevice && ugetc(udevice)!=3D0) {=0A=
+		device =3D uconvert_toascii(udevice, tmp3);=0A=
+	}=0A=
+	else {=0A=
+		device =3D "/dev/mouse";=0A=
+	}=0A=
 =0A=
 	/* Put Intellimouse into wheel mode */=0A=
 	if (intellimouse) {=0A=
--- allegro_original/src/linux/lmsegpmd.c	Thu May 10 09:11:57 2001=0A=
+++ allegro/src/linux/lmsegpmd.c	Fri May  4 18:48:54 2001=0A=
@@ -97,11 +97,19 @@=0A=
  */=0A=
 static int mouse_init (void)=0A=
 {=0A=
-	char tmp[80], tmp2[80];=0A=
+	char tmp[80], tmp2[80], tmp3[80];=0A=
 	AL_CONST char *device;=0A=
+	AL_CONST char *udevice;=0A=
 =0A=
 	/* Find the device filename */=0A=
-	device =3D get_config_string(NULL, uconvert_ascii("mouse_device", =
tmp), uconvert_ascii(DEVICE_FILENAME, tmp2));=0A=
+	udevice =3D get_config_string (NULL, uconvert_ascii ("mouse_device", =
tmp), uconvert_ascii(DEVICE_FILENAME, tmp2));=0A=
+	if(udevice && ugetc(udevice)!=3D0) {=0A=
+		device =3D uconvert_toascii(udevice, tmp3);=0A=
+	}=0A=
+	else {=0A=
+		device =3D DEVICE_FILENAME;=0A=
+	}=0A=
+=0A=
 =0A=
 	/* Open mouse device.  Devices are cool. */=0A=
 	intdrv.device =3D open (device, O_RDONLY | O_NONBLOCK);=0A=
--- allegro_original/src/linux/lmsems.c	Thu May 10 09:11:57 2001=0A=
+++ allegro/src/linux/lmsems.c	Fri May  4 18:49:46 2001=0A=
@@ -149,12 +149,20 @@=0A=
  */=0A=
 static int mouse_init (void)=0A=
 {=0A=
-	char tmp[80], tmp2[80];=0A=
+	char tmp[80], tmp2[80], tmp3[80];=0A=
 	AL_CONST char *device;=0A=
+	AL_CONST char *udevice;=0A=
 	struct termios t;=0A=
 =0A=
 	/* Find the device filename */=0A=
-	device =3D get_config_string (NULL, uconvert_ascii ("mouse_device", =
tmp), uconvert_ascii("/dev/mouse", tmp2));=0A=
+	udevice =3D get_config_string (NULL, uconvert_ascii ("mouse_device", =
tmp), uconvert_ascii("/dev/mouse", tmp2));=0A=
+	if(udevice && ugetc(udevice)!=3D0) {=0A=
+		device =3D uconvert_toascii(udevice, tmp3);=0A=
+	}=0A=
+	else {=0A=
+		device =3D "/dev/mouse";=0A=
+	}=0A=
+=0A=
 =0A=
 	/* Open mouse device.  Devices are cool. */=0A=
 	intdrv.device =3D open (device, O_RDONLY | O_NONBLOCK);=0A=
--- allegro_original/src/unix/uossmidi.c	Thu May 10 09:11:58 2001=0A=
+++ allegro/src/unix/uossmidi.c	Fri May  4 16:47:41 2001=0A=
@@ -131,6 +131,7 @@=0A=
    struct synth_info info;=0A=
    int num_synths, i, ret =3D 0;=0A=
    char *s;=0A=
+   char tmp[64];=0A=
 =0A=
    if (ioctl(fd, SNDCTL_SEQ_NRSYNTHS, &num_synths) =3D=3D -1)=0A=
       return 0;=0A=
@@ -152,17 +153,17 @@=0A=
 =0A=
    switch (info.synth_subtype) {=0A=
       case FM_TYPE_ADLIB:=0A=
-	 s =3D "Adlib";=0A=
+	 s =3D uconvert_ascii("Adlib", tmp);=0A=
 	 break;=0A=
       case FM_TYPE_OPL3:=0A=
-	 s =3D "OPL3";=0A=
+	 s =3D uconvert_ascii("OPL3", tmp);=0A=
 	 break;=0A=
       default:=0A=
-	 s =3D "Error!";=0A=
+	 s =3D uconvert_ascii("Error!", tmp);=0A=
 	 break;=0A=
    }=0A=
 =0A=
-   usprintf(seq_desc, "Open Sound System (%s)", s);=0A=
+   usprintf(seq_desc, uconvert_ascii("Open Sound System (%s)", NULL), =
s);=0A=
    midi_driver->desc =3D seq_desc;=0A=
 =0A=
    return ret;=0A=

------=_NextPart_000_0117_01C0DA01.68633B10--



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/