This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project wmaker-crm.git.
The branch, next has been updated
via fab03fd0f6aa80e9f2eff1813f553f64340120e4 (commit)
via 90c7b582d1acad57e87b8661d56df4f39a296fa3 (commit)
via 4d61a8ac5068596d16b3c6713fe1366d1b710c7c (commit)
via dcffbb65b6edee05f44d2109f8b12ddff0212467 (commit)
via 5f32e2d9e6a802ec7e9f6a9d6ae18bda0c411b78 (commit)
via 3f84bf415b68f6b6cbfe185b4729725132ad0d03 (commit)
via 4c5643b7c4375ba6aabc47c685d1d77faaec98ea (commit)
via 6ae56cc5a8aa9ed6ebf1048998ae6078a9cd1ad6 (commit)
via 5e2eb3c160fa807b43f5495ee57de008e68abde0 (commit)
via 27770d1735fc15b3c46262b543e666d408c07c65 (commit)
via a3497881b90912d22432382f54b28143a9d33e12 (commit)
from f3b40190496760801ff96969a6c18373fc6f9fc1 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://repo.or.cz/w/wmaker-crm.git/commit/fab03fd0f6aa80e9f2eff1813f553f64340120e4
commit fab03fd0f6aa80e9f2eff1813f553f64340120e4
Author: Christophe CURIS <[email protected]>
Date: Sun Nov 10 17:41:09 2013 +0100
wmaker: Do not allocate memory for a short lived string in
'selectSpecification'
It is not only not very efficient, but in present case it also participates
in memory fragmentation.
This patch replaces this with a stack allocated buffer with a buffer which
is way too large.
Signed-off-by: Christophe CURIS <[email protected]>
diff --git a/src/winspector.c b/src/winspector.c
index 8cb49df..1e185f5 100644
--- a/src/winspector.c
+++ b/src/winspector.c
@@ -993,26 +993,20 @@ static void textEditedObserver(void *observerData,
WMNotification *notification)
static void selectSpecification(WMWidget *bPtr, void *data)
{
InspectorPanel *panel = (InspectorPanel *) data;
- char *str;
+ char str[256];
WWindow *wwin = panel->inspected;
- int len;
if (bPtr == panel->defaultRb && (wwin->wm_instance || wwin->wm_class))
WMSetButtonEnabled(panel->applyBtn, False);
else
WMSetButtonEnabled(panel->applyBtn, True);
- len = 16 + strlen(wwin->wm_instance ? wwin->wm_instance : "?")
- + strlen(wwin->wm_class ? wwin->wm_class : "?");
-
- str = wmalloc(len);
-
- snprintf(str, len, _("Inspecting %s.%s"),
- wwin->wm_instance ? wwin->wm_instance : "?", wwin->wm_class ?
wwin->wm_class : "?");
+ snprintf(str, sizeof(str),
+ _("Inspecting %s.%s"),
+ wwin->wm_instance ? wwin->wm_instance : "?",
+ wwin->wm_class ? wwin->wm_class : "?");
wFrameWindowChangeTitle(panel->frame->frame, str);
-
- wfree(str);
}
static void selectWindow(WMWidget *bPtr, void *data)
http://repo.or.cz/w/wmaker-crm.git/commit/90c7b582d1acad57e87b8661d56df4f39a296fa3
commit 90c7b582d1acad57e87b8661d56df4f39a296fa3
Author: Christophe CURIS <[email protected]>
Date: Sun Nov 10 17:41:13 2013 +0100
WPrefs: Make the label internationalised for the texture option in dialog
window
As this label is being displayed in the window, it is a good idea to make
it translatable to the user's locale.
Signed-off-by: Christophe CURIS <[email protected]>
diff --git a/WPrefs.app/Appearance.c b/WPrefs.app/Appearance.c
index 2662471..c9ff182 100644
--- a/WPrefs.app/Appearance.c
+++ b/WPrefs.app/Appearance.c
@@ -297,13 +297,13 @@ static const struct {
const char *default_value;
const char *label;
} textureOptions[] = {
- { "FTitleBack", "(solid, black)", "[Focused]" },
- { "UTitleBack", "(solid, gray)", "[Unfocused]" },
- { "PTitleBack", "(solid, "#616161")", "[Owner of Focused]" },
- { "ResizebarBack", "(solid, gray)", "[Resizebar]" },
- { "MenuTitleBack", "(solid, black)", "[Menu Title]" },
- { "MenuTextBack", "(solid, gray)", "[Menu Item]" },
- { "IconBack", "(solid, gray)", "[Icon]" }
+ { "FTitleBack", "(solid, black)", N_("[Focused]") },
+ { "UTitleBack", "(solid, gray)", N_("[Unfocused]") },
+ { "PTitleBack", "(solid, "#616161")", N_("[Owner of Focused]") },
+ { "ResizebarBack", "(solid, gray)", N_("[Resizebar]") },
+ { "MenuTitleBack", "(solid, black)", N_("[Menu Title]") },
+ { "MenuTextBack", "(solid, gray)", N_("[Menu Item]") },
+ { "IconBack", "(solid, gray)", N_("[Icon]") }
};
#define RESIZEBAR_BEVEL -1
@@ -1966,7 +1966,7 @@ static void showData(_Panel * panel)
for (i = 0; i < wlengthof(textureOptions); i++) {
setupTextureFor(panel->texLs, textureOptions[i].key,
- textureOptions[i].default_value,
textureOptions[i].label, i);
+ textureOptions[i].default_value,
_(textureOptions[i].label), i);
panel->textureIndex[i] = i;
}
updatePreviewBox(panel, EVERYTHING);
http://repo.or.cz/w/wmaker-crm.git/commit/4d61a8ac5068596d16b3c6713fe1366d1b710c7c
commit 4d61a8ac5068596d16b3c6713fe1366d1b710c7c
Author: Christophe CURIS <[email protected]>
Date: Sun Nov 10 17:41:12 2013 +0100
WPrefs: Changed array of strings 'textureOptions' into a struct for
explicitness
The parameters for the textures were stored all together in an array
which made its usage error prone; now there a struct to clearly identify
which string is what, so it is clear in the source what's being done.
Signed-off-by: Christophe CURIS <[email protected]>
diff --git a/WPrefs.app/Appearance.c b/WPrefs.app/Appearance.c
index 734fa7f..2662471 100644
--- a/WPrefs.app/Appearance.c
+++ b/WPrefs.app/Appearance.c
@@ -292,14 +292,18 @@ static char *sampleColors[] = {
"black"
};
-static char *textureOptions[] = {
- "FTitleBack", "(solid, black)", "[Focused]",
- "UTitleBack", "(solid, gray)", "[Unfocused]",
- "PTitleBack", "(solid, "#616161")", "[Owner of Focused]",
- "ResizebarBack", "(solid, gray)", "[Resizebar]",
- "MenuTitleBack", "(solid, black)", "[Menu Title]",
- "MenuTextBack", "(solid, gray)", "[Menu Item]",
- "IconBack", "(solid, gray)", "[Icon]"
+static const struct {
+ const char *key;
+ const char *default_value;
+ const char *label;
+} textureOptions[] = {
+ { "FTitleBack", "(solid, black)", "[Focused]" },
+ { "UTitleBack", "(solid, gray)", "[Unfocused]" },
+ { "PTitleBack", "(solid, "#616161")", "[Owner of Focused]" },
+ { "ResizebarBack", "(solid, gray)", "[Resizebar]" },
+ { "MenuTitleBack", "(solid, black)", "[Menu Title]" },
+ { "MenuTextBack", "(solid, gray)", "[Menu Item]" },
+ { "IconBack", "(solid, gray)", "[Icon]" }
};
#define RESIZEBAR_BEVEL -1
@@ -1895,7 +1899,7 @@ static void createPanel(Panel * p)
panel->texturePanel = CreateTexturePanel(panel->parent);
}
-static void setupTextureFor(WMList * list, const char *key, char *defValue,
const char *title, int index)
+static void setupTextureFor(WMList *list, const char *key, const char
*defValue, const char *title, int index)
{
WMListItem *item;
TextureListItem *titem;
@@ -1960,9 +1964,9 @@ static void showData(_Panel * panel)
}
changeColorPage(panel->colP, panel);
- for (i = 0; i < sizeof(textureOptions) / (3 * sizeof(char *)); i++) {
- setupTextureFor(panel->texLs, textureOptions[i * 3],
- textureOptions[i * 3 + 1], textureOptions[i * 3
+ 2], i);
+ for (i = 0; i < wlengthof(textureOptions); i++) {
+ setupTextureFor(panel->texLs, textureOptions[i].key,
+ textureOptions[i].default_value,
textureOptions[i].label, i);
panel->textureIndex[i] = i;
}
updatePreviewBox(panel, EVERYTHING);
@@ -1977,10 +1981,10 @@ static void storeData(_Panel * panel)
WMListItem *item;
int i;
- for (i = 0; i < sizeof(textureOptions) / (sizeof(char *) * 3); i++) {
+ for (i = 0; i < wlengthof(textureOptions); i++) {
item = WMGetListItem(panel->texLs, panel->textureIndex[i]);
titem = (TextureListItem *) item->clientData;
- SetObjectForKey(titem->prop, textureOptions[i * 3]);
+ SetObjectForKey(titem->prop, textureOptions[i].key);
}
for (i = 0; i < 8; i++) {
http://repo.or.cz/w/wmaker-crm.git/commit/dcffbb65b6edee05f44d2109f8b12ddff0212467
commit dcffbb65b6edee05f44d2109f8b12ddff0212467
Author: Christophe CURIS <[email protected]>
Date: Sun Nov 10 17:41:11 2013 +0100
WPrefs: Changed array of strings 'colorOptions' into a struct for
explicitness
The parameters for the theme colors were stored all together in an array
which made its usage error prone; now there a struct to clearly identify
which string is what, so it the source is clearer on what's being done.
Signed-off-by: Christophe CURIS <[email protected]>
diff --git a/WPrefs.app/Appearance.c b/WPrefs.app/Appearance.c
index ca4396e..734fa7f 100644
--- a/WPrefs.app/Appearance.c
+++ b/WPrefs.app/Appearance.c
@@ -325,19 +325,22 @@ static char *textureOptions[] = {
#define CLIP_COL (1<<10)
#define CCLIP_COL (1<<11)
-static char *colorOptions[] = {
- "FTitleColor", "white",
- "UTitleColor", "black",
- "PTitleColor", "white",
- "MenuTitleColor", "white",
- "MenuTextColor", "black",
- "MenuDisabledColor", "#616161",
- "HighlightColor", "white",
- "HighlightTextColor", "black",
- "IconTitleColor", "white",
- "IconTitleBack", "black",
- "ClipTitleColor", "black",
- "CClipTitleColor", "#454045"
+static const struct {
+ const char *key;
+ const char *default_value;
+} colorOptions[] = {
+ { "FTitleColor", "white" },
+ { "UTitleColor", "black" },
+ { "PTitleColor", "white" },
+ { "MenuTitleColor", "white" },
+ { "MenuTextColor", "black" },
+ { "MenuDisabledColor", "#616161" },
+ { "HighlightColor", "white" },
+ { "HighlightTextColor", "black" },
+ { "IconTitleColor", "white" },
+ { "IconTitleBack", "black" },
+ { "ClipTitleColor", "black" },
+ { "CClipTitleColor", "#454045" }
};
static WMRect previewPositions[] = {
@@ -1922,7 +1925,7 @@ static void setupTextureFor(WMList * list, const char
*key, char *defValue, cons
static void showData(_Panel * panel)
{
int i;
- char *str;
+ const char *str;
str = GetStringForKey("MenuStyle");
if (str && strcasecmp(str, "flat") == 0) {
@@ -1942,12 +1945,12 @@ static void showData(_Panel * panel)
panel->titleAlignment = WACenter;
}
- for (i = 0; i < sizeof(colorOptions) / (2 * sizeof(char *)); i++) {
+ for (i = 0; i < wlengthof(colorOptions); i++) {
WMColor *color;
- str = GetStringForKey(colorOptions[i * 2]);
+ str = GetStringForKey(colorOptions[i].key);
if (!str)
- str = colorOptions[i * 2 + 1];
+ str = colorOptions[i].default_value;
if (!(color = WMCreateNamedColor(WMWidgetScreen(panel->box),
str, False))) {
color = WMCreateNamedColor(WMWidgetScreen(panel->box),
"#000000", False);
@@ -1986,7 +1989,7 @@ static void storeData(_Panel * panel)
str = WMGetColorRGBDescription(panel->colors[i]);
if (str) {
- SetStringForKey(str, colorOptions[i * 2]);
+ SetStringForKey(str, colorOptions[i].key);
wfree(str);
}
}
http://repo.or.cz/w/wmaker-crm.git/commit/5f32e2d9e6a802ec7e9f6a9d6ae18bda0c411b78
commit 5f32e2d9e6a802ec7e9f6a9d6ae18bda0c411b78
Author: Christophe CURIS <[email protected]>
Date: Sun Nov 10 17:41:10 2013 +0100
wmaker: Created an array to hold the maximize menu entries
The idea is that an array is easier to work with, when it's about to add,
remove or change entries, because all data end up stored in one place
instead of dispatched around the code.
It also makes code smaller as it avoids repetitions.
Signed-off-by: Christophe CURIS <[email protected]>
diff --git a/src/winmenu.c b/src/winmenu.c
index 6335ae8..5fa4886 100644
--- a/src/winmenu.c
+++ b/src/winmenu.c
@@ -73,19 +73,22 @@ enum
WO_ENTRIES
};
-enum
-{
- MAXC_V,
- MAXC_H,
- MAXC_LH,
- MAXC_RH,
- MAXC_TH,
- MAXC_BH,
- MAXC_LTC,
- MAXC_RTC,
- MAXC_LBC,
- MAXC_RBC,
- MAXC_MAXIMUS
+static const struct {
+ const char *label;
+ unsigned int shortcut_idx;
+ int maxim_direction;
+} menu_maximize_entries[] = {
+ { N_("Maximize vertically"), WKBD_VMAXIMIZE, MAX_VERTICAL },
+ { N_("Maximize horizontally"), WKBD_HMAXIMIZE, MAX_HORIZONTAL },
+ { N_("Maximize left half"), WKBD_LHMAXIMIZE, MAX_VERTICAL |
MAX_LEFTHALF },
+ { N_("Maximize right half"), WKBD_RHMAXIMIZE, MAX_VERTICAL |
MAX_RIGHTHALF },
+ { N_("Maximize top half"), WKBD_THMAXIMIZE, MAX_HORIZONTAL |
MAX_TOPHALF },
+ { N_("Maximize bottom half"), WKBD_BHMAXIMIZE, MAX_HORIZONTAL |
MAX_BOTTOMHALF },
+ { N_("Maximize left top corner"), WKBD_LTCMAXIMIZE, MAX_LEFTHALF |
MAX_TOPHALF },
+ { N_("Maximize right top corner"), WKBD_RTCMAXIMIZE, MAX_RIGHTHALF |
MAX_TOPHALF },
+ { N_("Maximize left bottom corner"), WKBD_LBCMAXIMIZE, MAX_LEFTHALF |
MAX_BOTTOMHALF },
+ { N_("Maximize right bottom corner"), WKBD_RBCMAXIMIZE, MAX_RIGHTHALF |
MAX_BOTTOMHALF },
+ { N_("Maximus: tiled maximization"), WKBD_MAXIMUS, MAX_MAXIMUS }
};
static void updateOptionsMenu(WMenu * menu, WWindow * wwin);
@@ -122,55 +125,10 @@ static void execMaximizeCommand(WMenu * menu, WMenuEntry
* entry)
{
WWindow *wwin = (WWindow *) entry->clientdata;
+ /* Parameter not used, but tell the compiler that it is ok */
(void) menu;
-
- switch (entry->order) {
- case MAXC_V:
- handleMaximize(wwin, MAX_VERTICAL);
- break;
-
- case MAXC_H:
- handleMaximize(wwin,MAX_HORIZONTAL);
- break;
-
- case MAXC_LH:
- handleMaximize(wwin,MAX_VERTICAL | MAX_LEFTHALF);
- break;
-
- case MAXC_RH:
- handleMaximize(wwin,MAX_VERTICAL | MAX_RIGHTHALF);
- break;
-
- case MAXC_TH:
- handleMaximize(wwin,MAX_HORIZONTAL | MAX_TOPHALF);
- break;
-
- case MAXC_BH:
- handleMaximize(wwin,MAX_HORIZONTAL | MAX_BOTTOMHALF);
- break;
-
- case MAXC_LTC:
- handleMaximize(wwin,MAX_LEFTHALF | MAX_TOPHALF);
- break;
-
- case MAXC_RTC:
- handleMaximize(wwin,MAX_RIGHTHALF | MAX_TOPHALF);
- break;
-
- case MAXC_LBC:
- handleMaximize(wwin,MAX_LEFTHALF | MAX_BOTTOMHALF);
- break;
-
- case MAXC_RBC:
- handleMaximize(wwin,MAX_RIGHTHALF | MAX_BOTTOMHALF);
- break;
-
- case MAXC_MAXIMUS:
- handleMaximize(wwin,MAX_MAXIMUS);
- break;
-
- }
+ handleMaximize(wwin,
menu_maximize_entries[entry->order].maxim_direction);
}
static void updateUnmaximizeShortcut(WMenuEntry * entry, int flags)
@@ -479,39 +437,12 @@ static void updateOptionsMenu(WMenu * menu, WWindow *
wwin)
static void updateMaximizeMenu(WMenu * menu, WWindow * wwin)
{
WMenu *smenu = menu->cascades[menu->entries[MC_OTHERMAX]->cascade];
+ int i;
- smenu->entries[MAXC_V]->clientdata = wwin;
- smenu->entries[MAXC_V]->rtext =
GetShortcutKey(wKeyBindings[WKBD_VMAXIMIZE]);
-
- smenu->entries[MAXC_H]->clientdata = wwin;
- smenu->entries[MAXC_H]->rtext =
GetShortcutKey(wKeyBindings[WKBD_HMAXIMIZE]);
-
- smenu->entries[MAXC_LH]->clientdata = wwin;
- smenu->entries[MAXC_LH]->rtext =
GetShortcutKey(wKeyBindings[WKBD_LHMAXIMIZE]);
-
- smenu->entries[MAXC_RH]->clientdata = wwin;
- smenu->entries[MAXC_RH]->rtext =
GetShortcutKey(wKeyBindings[WKBD_RHMAXIMIZE]);
-
- smenu->entries[MAXC_TH]->clientdata = wwin;
- smenu->entries[MAXC_TH]->rtext =
GetShortcutKey(wKeyBindings[WKBD_THMAXIMIZE]);
-
- smenu->entries[MAXC_BH]->clientdata = wwin;
- smenu->entries[MAXC_BH]->rtext =
GetShortcutKey(wKeyBindings[WKBD_BHMAXIMIZE]);
-
- smenu->entries[MAXC_LTC]->clientdata = wwin;
- smenu->entries[MAXC_LTC]->rtext =
GetShortcutKey(wKeyBindings[WKBD_LTCMAXIMIZE]);
-
- smenu->entries[MAXC_RTC]->clientdata = wwin;
- smenu->entries[MAXC_RTC]->rtext =
GetShortcutKey(wKeyBindings[WKBD_RTCMAXIMIZE]);
-
- smenu->entries[MAXC_LBC]->clientdata = wwin;
- smenu->entries[MAXC_LBC]->rtext =
GetShortcutKey(wKeyBindings[WKBD_LBCMAXIMIZE]);
-
- smenu->entries[MAXC_RBC]->clientdata = wwin;
- smenu->entries[MAXC_RBC]->rtext =
GetShortcutKey(wKeyBindings[WKBD_RBCMAXIMIZE]);
-
- smenu->entries[MAXC_MAXIMUS]->clientdata = wwin;
- smenu->entries[MAXC_MAXIMUS]->rtext =
GetShortcutKey(wKeyBindings[WKBD_MAXIMUS]);
+ for (i = 0; i < smenu->entry_no; i++) {
+ smenu->entries[i]->clientdata = wwin;
+ smenu->entries[i]->rtext =
GetShortcutKey(wKeyBindings[menu_maximize_entries[i].shortcut_idx]);
+ }
smenu->flags.realized = 0;
wMenuRealize(smenu);
@@ -575,6 +506,7 @@ static WMenu *makeOptionsMenu(WScreen * scr)
static WMenu *makeMaximizeMenu(WScreen * scr)
{
WMenu *menu;
+ int i;
menu = wMenuCreate(scr, NULL, False);
if (!menu) {
@@ -582,17 +514,8 @@ static WMenu *makeMaximizeMenu(WScreen * scr)
return NULL;
}
- (void) wMenuAddCallback(menu, _("Maximize vertically"),
execMaximizeCommand, NULL);
- (void) wMenuAddCallback(menu, _("Maximize horizontally"),
execMaximizeCommand, NULL);
- (void) wMenuAddCallback(menu, _("Maximize left half"),
execMaximizeCommand, NULL);
- (void) wMenuAddCallback(menu, _("Maximize right half"),
execMaximizeCommand, NULL);
- (void) wMenuAddCallback(menu, _("Maximize top half"),
execMaximizeCommand, NULL);
- (void) wMenuAddCallback(menu, _("Maximize bottom half"),
execMaximizeCommand, NULL);
- (void) wMenuAddCallback(menu, _("Maximize left top corner"),
execMaximizeCommand, NULL);
- (void) wMenuAddCallback(menu, _("Maximize right top corner"),
execMaximizeCommand, NULL);
- (void) wMenuAddCallback(menu, _("Maximize left bottom corner"),
execMaximizeCommand, NULL);
- (void) wMenuAddCallback(menu, _("Maximize right bottom corner"),
execMaximizeCommand, NULL);
- (void) wMenuAddCallback(menu, _("Maximus: tiled maximization"),
execMaximizeCommand, NULL);
+ for (i = 0; i < wlengthof(menu_maximize_entries); i++)
+ wMenuAddCallback(menu, _(menu_maximize_entries[i].label),
execMaximizeCommand, NULL);
return menu;
}
http://repo.or.cz/w/wmaker-crm.git/commit/3f84bf415b68f6b6cbfe185b4729725132ad0d03
commit 3f84bf415b68f6b6cbfe185b4729725132ad0d03
Author: Christophe CURIS <[email protected]>
Date: Sun Nov 10 17:41:08 2013 +0100
wmaker: Avoid multiple calls to gettext
The original code called gettext twice every time, the new code calls it
only once.
Signed-off-by: Christophe CURIS <[email protected]>
diff --git a/src/workspace.c b/src/workspace.c
index 4e619ef..1365cc9 100644
--- a/src/workspace.c
+++ b/src/workspace.c
@@ -94,8 +94,15 @@ int wWorkspaceNew(WScreen *scr)
wspace->clip = NULL;
if (!wspace->name) {
- wspace->name = wmalloc(strlen(_("Workspace %i")) + 8);
- sprintf(wspace->name, _("Workspace %i"),
w_global.workspace.count);
+ static const char *new_name = NULL;
+ static size_t name_length;
+
+ if (new_name == NULL) {
+ new_name = _("Workspace %i");
+ name_length = strlen(new_name) + 8;
+ }
+ wspace->name = wmalloc(name_length);
+ snprintf(wspace->name, name_length, new_name,
w_global.workspace.count);
}
if (!wPreferences.flags.noclip)
http://repo.or.cz/w/wmaker-crm.git/commit/4c5643b7c4375ba6aabc47c685d1d77faaec98ea
commit 4c5643b7c4375ba6aabc47c685d1d77faaec98ea
Author: Christophe CURIS <[email protected]>
Date: Sun Nov 10 17:41:07 2013 +0100
wmaker: Minor improvements to function 'shade_animate' when empty on purpose
When animations are disabled, we still create the function but we make it
empty to keep the rest of the code simple. This patch does:
- mark the function inline, to increase the probability that the compiler
will not generate the function at all;
- mark arguments as unused to avoid some compilation warnings.
Signed-off-by: Christophe CURIS <[email protected]>
diff --git a/src/actions.c b/src/actions.c
index 2087953..1087117 100644
--- a/src/actions.c
+++ b/src/actions.c
@@ -84,7 +84,14 @@ static int compareTimes(Time t1, Time t2)
#ifdef ANIMATIONS
static void shade_animate(WWindow *wwin, Bool what);
#else
-static void shade_animate(WWindow *wwin, Bool what) { }
+static inline void shade_animate(WWindow *wwin, Bool what) {
+ /*
+ * This function is empty on purpose, so tell the compiler
+ * to not warn about parameters being not used
+ */
+ (void) wwin;
+ (void) what;
+}
#endif
/*
http://repo.or.cz/w/wmaker-crm.git/commit/6ae56cc5a8aa9ed6ebf1048998ae6078a9cd1ad6
commit 6ae56cc5a8aa9ed6ebf1048998ae6078a9cd1ad6
Author: Christophe CURIS <[email protected]>
Date: Sun Nov 10 17:41:06 2013 +0100
WINGs: Do not allocate memory for a fixed-size short-lived buffer
Allocating memory with 'malloc' has a cost and participate to memory
fragmentation, so for a temporary buffer that has a fixed size let's
prefer allocating it on the stack.
Signed-off-by: Christophe CURIS <[email protected]>
diff --git a/WINGs/wfilepanel.c b/WINGs/wfilepanel.c
index 6785beb..10eea33 100644
--- a/WINGs/wfilepanel.c
+++ b/WINGs/wfilepanel.c
@@ -693,32 +693,35 @@ static void normalizePath(char *s)
static void deleteFile(WMWidget *widget, void *p_panel)
{
WMFilePanel *panel = p_panel;
- char *file, *buffer;
+ char *file;
+ char buffer[512];
struct stat filestat;
WMScreen *scr = WMWidgetScreen(panel->win);
-#define __msgbufsize__ 512
/* Parameter not used, but tell the compiler that it is ok */
(void) widget;
- buffer = wmalloc(__msgbufsize__);
file = getCurrentFileName(panel);
normalizePath(file);
if (stat(file, &filestat) == -1) {
- snprintf(buffer, __msgbufsize__, _("Can not find %s: %s"),
file, strerror(errno));
+ snprintf(buffer, sizeof(buffer),
+ _("Can not find %s: %s"),
+ file, strerror(errno));
showError(scr, panel->win, buffer, NULL);
goto out;
}
- snprintf(buffer, __msgbufsize__, _("Delete %s %s?"),
+ snprintf(buffer, sizeof(buffer), _("Delete %s %s?"),
S_ISDIR(filestat.st_mode) ? _("directory") : _("file"), file);
if (!WMRunAlertPanel(WMWidgetScreen(panel->win), panel->win,
_("Warning"), buffer, _("OK"), _("Cancel"), NULL))
{
if (remove(file) == -1) {
- snprintf(buffer, __msgbufsize__, _("Removing %s failed:
%s"), file, strerror(errno));
+ snprintf(buffer, sizeof(buffer),
+ _("Removing %s failed: %s"),
+ file, strerror(errno));
showError(scr, panel->win, buffer, NULL);
} else {
char *s = strrchr(file, '/');
@@ -729,11 +732,8 @@ static void deleteFile(WMWidget *widget, void *p_panel)
}
out:
- if (buffer)
- wfree(buffer);
if (file)
wfree(file);
-#undef __msgbufsize__
}
static void goUnmount(WMWidget *widget, void *p_panel)
http://repo.or.cz/w/wmaker-crm.git/commit/5e2eb3c160fa807b43f5495ee57de008e68abde0
commit 5e2eb3c160fa807b43f5495ee57de008e68abde0
Author: Christophe CURIS <[email protected]>
Date: Sun Nov 10 17:41:05 2013 +0100
WINGs: Minor improvments in 'closestListItem' function
The check on length of string before comparing is not necessary
because this will be checked as part of strcmp; the check won't
save time and may actually cost.
As the number of element in the array is not going to change during
the loop, took the call to 'WMGetArrayItemCount' outside the loop
to be faster (and ease compiler's optimisation work).
Signed-off-by: Christophe CURIS <[email protected]>
diff --git a/WINGs/wfilepanel.c b/WINGs/wfilepanel.c
index 8219ee6..6785beb 100644
--- a/WINGs/wfilepanel.c
+++ b/WINGs/wfilepanel.c
@@ -93,16 +93,16 @@ static int closestListItem(WMList * list, const char *text,
Bool exact)
{
WMListItem *item;
WMArray *items = WMGetListItems(list);
- int i, len = strlen(text);
+ int i, nb_item, len = strlen(text);
if (len == 0)
return -1;
- for (i = 0; i < WMGetArrayItemCount(items); i++) {
+ nb_item = WMGetArrayItemCount(items);
+ for (i = 0; i < nb_item; i++) {
item = WMGetFromArray(items, i);
- if (strlen(item->text) >= len &&
- ((exact && strcmp(item->text, text) == 0) ||
- (!exact && strncmp(item->text, text, len) == 0))) {
+ if ((exact && strcmp(item->text, text) == 0) ||
+ (!exact && strncmp(item->text, text, len) == 0)) {
return i;
}
}
http://repo.or.cz/w/wmaker-crm.git/commit/27770d1735fc15b3c46262b543e666d408c07c65
commit 27770d1735fc15b3c46262b543e666d408c07c65
Author: Christophe CURIS <[email protected]>
Date: Sun Nov 10 17:41:04 2013 +0100
configure: Add check on function prototypes when debug is enabled
Signed-off-by: Christophe CURIS <[email protected]>
diff --git a/configure.ac b/configure.ac
index 5c32ca8..bbcdcbb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -125,6 +125,10 @@ AS_IF([test "x$debug" = "xyes"],
dnl
dnl Use of 'sizeof()' on inappropriate pointer types
AX_CFLAGS_GCC_OPTION([-Wpointer-arith])
+ dnl
+ dnl Having more than 1 prototype for a function makes code updates
+ dnl more difficult, so try to avoid it
+ AX_CFLAGS_GCC_OPTION([-Wredundant-decls])
], [dnl
dnl When debug not enabled, we try to avoid some non-necessary
dnl messages from the compiler
http://repo.or.cz/w/wmaker-crm.git/commit/a3497881b90912d22432382f54b28143a9d33e12
commit a3497881b90912d22432382f54b28143a9d33e12
Author: Christophe CURIS <[email protected]>
Date: Sun Nov 10 17:41:03 2013 +0100
configure: Minor changes to option parsing for consistency
The idea is to:
- have a consistent looking file by using autoconf macros
- provide better feedback on improper option usage
Signed-off-by: Christophe CURIS <[email protected]>
diff --git a/configure.ac b/configure.ac
index fe92ba7..5c32ca8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -190,18 +190,18 @@ AC_ARG_WITH(incs-from, AS_HELP_STRING([--with-incs-from],
[pass compiler flags t
dnl Boehm GC
dnl ========
-with_boehm_gc=no
AC_ARG_ENABLE([boehm-gc],
[AS_HELP_STRING([--enable-boehm-gc], [use Boehm GC instead of the default
libc malloc() [default=no]])],
- [with_boehm_gc=$enableval])
-
+ [AS_CASE(["$enableval"],
+ [yes], [with_boehm_gc=yes],
+ [no], [with_boehm_gc=no],
+ [AC_MSG_ERROR([bad value $enableval for --enable-boehm-gc])] )],
+ [with_boehm_gc=no])
AS_IF([test "x$with_boehm_gc" = "xyes"],
AC_SEARCH_LIBS([GC_malloc], [gc],
[AC_DEFINE(USE_BOEHM_GC, 1, [Define if Boehm GC is to be used])],
- [AC_MSG_FAILURE([--enable-boehm-gc specified but test for libgc
failed])],
- []
- )
-)
+ [AC_MSG_FAILURE([--enable-boehm-gc specified but test for libgc
failed])]))
+
dnl LCOV
dnl ====
@@ -212,13 +212,11 @@ AC_ARG_ENABLE([lcov],
AS_IF([test "x$enable_lcov" != "xno"],
[AX_CFLAGS_GCC_OPTION(-fprofile-arcs -ftest-coverage)
- if test "x$enable_lcov" = "xyes"; then
- lcov_output_directory="coverage-report"
- else
- lcov_output_directory="${enable_lcov}/coverage-report"
- fi
- AC_SUBST(lcov_output_directory)]
-)
+ AS_IF([test "x$enable_lcov" = "xyes"],
+ [lcov_output_directory="coverage-report"],
+ [lcov_output_directory="${enable_lcov}/coverage-report"])
+ AC_SUBST(lcov_output_directory)])
+
AM_CONDITIONAL([USE_LCOV], [test "x$enable_lcov" != "xno"])
dnl
-----------------------------------------------------------------------
Summary of changes:
WINGs/wfilepanel.c | 28 +++++-----
WPrefs.app/Appearance.c | 71 ++++++++++++++------------
configure.ac | 30 ++++++-----
src/actions.c | 9 +++-
src/winmenu.c | 129 +++++++++-------------------------------------
src/winspector.c | 16 ++----
src/workspace.c | 11 +++-
7 files changed, 117 insertions(+), 177 deletions(-)
repo.or.cz automatic notification. Contact project admin [email protected]
if you want to unsubscribe, or site admin [email protected] if you receive
no reply.
--
wmaker-crm.git ("The Window Maker window manager")
--
To unsubscribe, send mail to [email protected].