[AD] Five patches

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


Title: Five patches

Annie worked some more on the unicode stuff, and she has some patches
against wip 38.



Hi all !

First three small patches:

All the calls to allegro_message in the library are given an ASCII format
string, but allegro_message expects current encoding.  allegro_message.diff
fixes this.

fix_filename_path converts an already converted string.  fix_filename_path.diff
fixes this.

al_getdcwd returns an ASCII string, instead of a current encoding one.
mfile.diff fixes this (be carefull, end of line is \n and not \r).


Then two bigger patches:

For simplifying the conversion between encoding format, i have created a simple
memory pool. Usage example:

      void error(int err_number, char *ascii_err_string)
      {
         /* Creates the memory pool */
         UBUFFERS *b = create_ubuffers();

         /* Calls to ubconvert allocate memory in the pool */
         textprintf(
            screen, font, 0, 0, makecol(255, 255, 255),
            ubconvert(b, "Error %d: %s", U_ASCII, U_CURRENT), err_number,
            ubconvert(b, ascii_err_string, U_ASCII, U_CURRENT)
         );

         /* Free all the buffers allocated in the pool */
         destroy_ubuffers(b);
      }

intead of:

      void error(int err_number, char *ascii_err_string)
      {
         char format_string[256];
         char error_string[256];

         textprintf(
            screen, font, 0, 0, makecol(255, 255, 255),
            uconvert_ascii("Error %d: %s", format_string), err_number,
            uconvert_ascii(ascii_err_string, error_string)
         );
      }

Notes:
 - This can be slower than uconvert() because memory is always allocated.
 - When using buffers with static length it is possible that the end of the
   string is lost, but not with UBUFFERS.
 - I have also added _uconvert_dup and uconvert_dup which convert and duplicate
   a string.  Also ubconvert_ascii and ubconvert_toascii are defined.
 - Each time a call to ubconvert is made, a new string is allocated and is not
   free'ed before calling destroy_ubuffers. Therefore, the next code fragment
   can use much memory:

      for (i=0; i<NUM; i++) {
        textout(bmp, font, ubconvert(b, array[i], U_ASCII, U_CURRENT), x, y, c);
      }


ubuffers.diff adds these functions to the lib and the doc.  ubuffers_usage.diff
modifies examples/exgui.c to use UBUFFERS.

--
Annie Testes


--
Vincent Penquerc'h

 

Attachment: allegro_message.diff
Description: Binary data

Attachment: fix_filename_path.diff
Description: Binary data

Attachment: mfile.diff
Description: Binary data

Attachment: ubuffers.diff
Description: Binary data

Attachment: ubuffers_usage.diff
Description: Binary data



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