This is a patch for the glib-1.2.6

by Martin Oberzalek <[email protected]>

I added some BASIC string functions to the glib:

BASIC        GLIB                                                           DESCRIPTION
LEFT$        #define g_strleft(text, len) g_strndup(text, len)              only to complete the functions
RIGHT$       gchar* g_strright(gchar *text, gint len)                       same as g_strleft, but fromthe right side of the string
MID$         gchar* g_strmid(gchar *text, guint pos, guint len)             copies a string out of a string
INSTR$       gint g_strinstr(gchar *text, gchar* word)                      finds a string in a string and gives it's position back


These functions are very useful for porting applications from BASIC to C
I actually port eliza, so I needed them.
You can parse commands very well with them, and the rest of the g_str* functions.

I hope you will find it also useful and add it to the glib library

At last here is an example:

int main()
{
 int i;
 gchar *text = "This is the example text for the g_strinstr function";
 gchar *searchword = "example";
 gchar *ttext;

 g_print("Start\n");

 i = g_strinstr( text, searchword);

 if( i >= 0 ) g_print("Success! %s on postition: %d\n",searchword, i);
 else g_print("Failed!\n");

 ttext = g_strright( text, strlen(text)- i - strlen(searchword));
 g_print("%s\n",ttext);
 g_free(ttext);

 ttext = g_strmid(text, i, strlen(searchword));
 g_print("%s\n",ttext);
 g_free(ttext);

 g_print("Stop\n");

 return 0;
}