From 6ebf74a468ea6c4c667a0592aa59683f745bfdfe Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Fri, 7 Aug 2015 11:44:48 +0200 Subject: Fixed some issues with strings --- Linux_C_12/cCrossCallWindows_121.c | 3 +-- Linux_C_12/cpicture_121.c | 5 ++++- Linux_C_12/util_121.c | 28 ++++++++++++++-------------- Linux_C_12/util_121.h | 2 ++ 4 files changed, 21 insertions(+), 17 deletions(-) diff --git a/Linux_C_12/cCrossCallWindows_121.c b/Linux_C_12/cCrossCallWindows_121.c index 88f70e0..9950a52 100644 --- a/Linux_C_12/cCrossCallWindows_121.c +++ b/Linux_C_12/cCrossCallWindows_121.c @@ -1397,7 +1397,7 @@ void EvalCcRqCREATEDIALOG (CrossCallInfo *pcci) // textptr,parentptr,behindPtr; pwintitle = (const gchar *) pcci->p1; dialog = gtk_dialog_new(); - gtk_dialog_set_has_separator(GTK_DIALOG(dialog), gtk_false()); + gtk_dialog_set_has_separator(GTK_DIALOG(dialog), gtk_true()); gtk_window_set_resizable(GTK_WINDOW(dialog), gtk_false()); gtk_signal_connect (GTK_OBJECT(dialog), "delete-event", GTK_SIGNAL_FUNC(dialog_close_handler), @@ -1419,7 +1419,6 @@ void EvalCcRqCREATEDIALOG (CrossCallInfo *pcci) // textptr,parentptr,behindPtr; gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), fixed, TRUE, TRUE, 0); gtk_widget_show(fixed); - rprintf("Sending dialog to clean: %p / %p\n", dialog, (int64_t) dialog); SendMessage1ToClean (CcWmINITDIALOG, (int64_t) dialog); x = gCci.p1; diff --git a/Linux_C_12/cpicture_121.c b/Linux_C_12/cpicture_121.c index c036587..542bf24 100644 --- a/Linux_C_12/cpicture_121.c +++ b/Linux_C_12/cpicture_121.c @@ -1362,9 +1362,12 @@ void WinGetStringWidth (CLEAN_STRING string, CLEAN_STRING fontName, gint style, GtkWidget *widget; gchar* fName; gboolean inDrawIsWidget; + gchar* cstr; printf("WinGetStringWidth\n"); fName = cstring(fontName); + cstr = cstring(string); + inDrawIsWidget = GTK_IS_WIDGET(drawable); if (! inDrawIsWidget) @@ -1389,7 +1392,7 @@ void WinGetStringWidth (CLEAN_STRING string, CLEAN_STRING fontName, gint style, pango_context_set_font_description(pc, fontDesc); pl = pango_layout_new(pc); - pango_layout_set_text(pl, string->characters, string->length); + pango_layout_set_text(pl, cstr, strlen(cstr)); pango_layout_get_pixel_size(pl, width, NULL); g_object_unref(G_OBJECT(pl)); diff --git a/Linux_C_12/util_121.c b/Linux_C_12/util_121.c index 544cff6..89d5b4f 100644 --- a/Linux_C_12/util_121.c +++ b/Linux_C_12/util_121.c @@ -137,18 +137,18 @@ int rabs (int i) char * cstring (CLEAN_STRING s) { - static char *cstr = (char *) NULL; + char* chars = rmalloc(CleanStringLength(s) + 1); - rprintf("{cstring"); - if (cstr) - { - rfree (cstr); - } + static char *cstr = (char*) NULL; + cstr = rmalloc(CleanStringLength(s) + 1 + sizeof(int)); + + int i; + for (i=0;i < CleanStringLength(s); i++) + chars[i] = CleanStringCharacters(s)[i]; + chars[i] = 0; + + rsncopy(cstr, chars, CleanStringLength(s) + 1); - cstr = (char *) rmalloc ((s->length) + 1); - rsncopy (cstr, s->characters, s->length); - cstr[s->length] = 0; -/* rprintf("}\n"); */ return cstr; } /* cstring */ @@ -1580,10 +1580,10 @@ void printMessage (char *fname, HWND hWin, UINT uMess, WPARAM wPara, LPARAM lPar } /* printMessage */ #endif -gchar *createMnemonicString(gchar *source) +gchar* createMnemonicString(gchar* source) { - gchar *dest; - gchar *s; + gchar* dest; + static gchar* s; printf("createMnemonicString\n"); if (source == NULL) @@ -1616,7 +1616,7 @@ gchar *createMnemonicString(gchar *source) } *dest = 0; - printf("Generated Mnemonic: %s\n", s); + printf("Generated Mnemonic: %p, %s\n", s, s); return s; } diff --git a/Linux_C_12/util_121.h b/Linux_C_12/util_121.h index 8bdcf76..14091f9 100644 --- a/Linux_C_12/util_121.h +++ b/Linux_C_12/util_121.h @@ -120,3 +120,5 @@ extern void printCCI( CrossCallInfo *pcci ); #endif #endif + +gchar* createMnemonicString(gchar*); -- cgit v1.2.3