Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 17 additions & 12 deletions src/FSBrowser.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <WINGs/WINGsP.h>
#include <WMaker.h>
#include <math.h> /* for : double rint (double) */
#include <stdint.h>

#include "FSBrowser.h"

Expand Down Expand Up @@ -174,7 +175,7 @@ void FSSetBrowserMaxVisibleColumns(FSBrowser* bPtr, int columns)
int curMaxVisibleColumns;
int newFirstVisibleColumn = 0;

assert((int)bPtr);
assert(bPtr);

columns = (columns < MIN_VISIBLE_COLUMNS) ? MIN_VISIBLE_COLUMNS : columns;
columns = (columns > MAX_VISIBLE_COLUMNS) ? MAX_VISIBLE_COLUMNS : columns;
Expand Down Expand Up @@ -320,7 +321,7 @@ removeColumn(FSBrowser* bPtr, int column)
WMList** clist;
char** tlist;

assert((int)bPtr);
assert(bPtr);

column = (column < 0) ? 0 : column;
if (column >= bPtr->columnCount) {
Expand Down Expand Up @@ -690,6 +691,8 @@ scrollCallback(WMWidget* scroller, void* self)

} break;

case WSDecrementWheel:
case WSIncrementWheel:
case WSKnobSlot:
case WSNoPart:
/* do nothing */
Expand Down Expand Up @@ -833,18 +836,19 @@ char* FSGetBrowserPathToColumn(FSBrowser* bPtr, int column)
}

/* get the path */
path = wmalloc(size + (column + 1) * strlen(bPtr->pathSeparator) + 1);
size_t pathSize = size + (column + 1) * strlen(bPtr->pathSeparator) + 1;
path = wmalloc(pathSize);
/* ignore first / */
*path = 0;
for (i = 0; i <= column; i++) {
strcat(path, bPtr->pathSeparator);
strlcat(path, bPtr->pathSeparator, pathSize);
item = WMGetListSelectedItem(bPtr->columns[i]);
if (!item)
break;
/* if(bPtr->parseItem) */
/* strcat(path, (*bPtr->parseItem)(item)); */
/* strlcat(path, (*bPtr->parseItem)(item), pathSize); */
/* else */
strcat(path, item->text);
strlcat(path, item->text, pathSize);
}

return path;
Expand Down Expand Up @@ -1072,7 +1076,7 @@ static void
listSelectionObserver(void* observerData, WMNotification* notification)
{
FSBrowser* bPtr = (FSBrowser*)observerData;
int column, item = (int)WMGetNotificationClientData(notification);
int column, item = (int)(intptr_t)WMGetNotificationClientData(notification);
WMList* lPtr = (WMList*)WMGetNotificationObject(notification);

for (column = 0; column < bPtr->usedColumnCount; column++)
Expand Down Expand Up @@ -1177,23 +1181,24 @@ static char*
createTruncatedString(WMFont* font, char* text, int* textLen, int width)
{
int dLen = WMWidthOfString(font, ".", 1);
char* textBuf = (char*)wmalloc((*textLen) + 4);
size_t bufSize = (*textLen) + 4;
char* textBuf = (char*)wmalloc(bufSize);

if (width >= 3 * dLen) {
int dddLen = 3 * dLen;
int tmpTextLen = *textLen;

strcpy(textBuf, text);
strlcpy(textBuf, text, bufSize);
while (tmpTextLen
&& (WMWidthOfString(font, textBuf, tmpTextLen) + dddLen > width))
tmpTextLen--;
strcpy(textBuf + tmpTextLen, "...");
strlcpy(textBuf + tmpTextLen, "...", bufSize - tmpTextLen);
*textLen = tmpTextLen + 3;
} else if (width >= 2 * dLen) {
strcpy(textBuf, "..");
strlcpy(textBuf, "..", bufSize);
*textLen = 2;
} else if (width >= dLen) {
strcpy(textBuf, ".");
strlcpy(textBuf, ".", bufSize);
*textLen = 1;
} else {
*textBuf = '\0';
Expand Down
5 changes: 3 additions & 2 deletions src/FSFileView.c
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ FSCreateFileView(FSViewer* fsViewer, char* path, Bool primary)

fView->fileView = WMCreateWindow(fView->scr, "fileView");
WMSetWindowTitle(fView->fileView, _("FileView"));
if ((fView->primary == False)) {
if (fView->primary == False) {
WMSetWindowCloseAction(fView->fileView, FSDestroyFileView,
(void*)fView);
}
Expand Down Expand Up @@ -415,7 +415,7 @@ FSCreateFileView(FSViewer* fsViewer, char* path, Bool primary)
fView->size->width_inc = cw + COLUMN_PADDING;
fView->size->height_inc = 1;
fView->size->flags = (USSize | PSize | PMinSize | PMaxSize | PResizeInc);
if ((fView->primary == True)) {
if (fView->primary == True) {
fView->size->x = fView->x;
fView->size->y = fView->y;
fView->size->flags |= (USPosition | PPosition);
Expand Down Expand Up @@ -563,6 +563,7 @@ void FSUpdateFileViewPath(FSFileView* fileView, FileAction action,

switch (action) {
case FileCopy:
case FileLink:
FSUpdateFileBrowser(fileView->fileBrowser, action, src, dest);
break;
case FileMove:
Expand Down
14 changes: 9 additions & 5 deletions src/FSFinder.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <X11/Xutil.h>
#include <X11/keysym.h>
#include <limits.h>
#include <stdint.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <unistd.h>
Expand Down Expand Up @@ -207,7 +208,7 @@ notificationObserver(void* self, WMNotification* notif)
WMResizeWidget(finder->list,
finder->w - (PADY * 2), finder->h - LISTX - (PADY * 2));
}
} else if ((int)WMGetNotificationClientData(notif) == WMReturnTextMovement) {
} else if ((int)(intptr_t)WMGetNotificationClientData(notif) == WMReturnTextMovement) {
populateList(finder);
}
}
Expand All @@ -231,15 +232,18 @@ populateList(FSFinder* finder)
* and the second should be 0, maybe it's LIFO
*/
if (WMGetButtonSelected(finder->findRadioBtns[0]) == 1) {
cmd = (char*)wmalloc(strlen(str) + 10);
sprintf(cmd, "locate \"%s\"", str);
size_t cmdLen = strlen(str) + 10;
cmd = (char*)wmalloc(cmdLen);
snprintf(cmd, cmdLen, "locate \"%s\"", str);
} else {
char* path;
size_t cmdLen;

path = FSGetFSViewerPath(finder->fsViewer);
cmd = (char*)wmalloc(strlen(str) + strlen(path) + 24);
cmdLen = strlen(str) + strlen(path) + 24;
cmd = (char*)wmalloc(cmdLen);

sprintf(cmd, "find \"%s\" -name \"%s\" -print", path, str);
snprintf(cmd, cmdLen, "find \"%s\" -name \"%s\" -print", path, str);
}

if ((f = popen(cmd, "r")) == NULL)
Expand Down
8 changes: 6 additions & 2 deletions src/FSPanel.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <WINGs/WINGsP.h>
#include <X11/Xatom.h>
#include <X11/keysym.h>
#include <stdint.h>

static FSSelectIconPanel* FSCreateSelectIconPanel(WMWindow*,
char*, char*);
Expand Down Expand Up @@ -1125,7 +1126,7 @@ endedEditingObserver(void* observerData, WMNotification* notification)
FSAppInputPanel* appInput = (FSAppInputPanel*)observerData;
WMTextField* tPtr = (WMTextField*)WMGetNotificationObject(notification);

if ((int)WMGetNotificationClientData(notification) == WMReturnTextMovement
if ((int)(intptr_t)WMGetNotificationClientData(notification) == WMReturnTextMovement
&& tPtr == appInput->nameField) {
char* txt = WMGetTextFieldText(appInput->nameField);
if (strcmp("", txt)) {
Expand Down Expand Up @@ -1384,6 +1385,7 @@ FSCreateSelectIconPanel(WMWindow* owner, char* title, char* str)
WMLabel* l;
WMPixmap* pixmap;
char* txt = NULL;
int txtAllocated = 0;
WMFont* aFont;

if (!(selIcon = (FSSelectIconPanel*)wmalloc(sizeof(FSSelectIconPanel))))
Expand All @@ -1397,6 +1399,8 @@ FSCreateSelectIconPanel(WMWindow* owner, char* title, char* str)
txt = FSGetStringForName("ICONDIR");
if (!txt)
txt = ICONDIR;
else
txtAllocated = 1;

selIcon->xpmDir = (char*)wmalloc(strlen(txt) + 5);
strcpy(selIcon->xpmDir, txt);
Expand All @@ -1406,7 +1410,7 @@ FSCreateSelectIconPanel(WMWindow* owner, char* title, char* str)
strcpy(selIcon->pngDir, txt);
strcat(selIcon->pngDir, "/png");

if (txt != ICONDIR)
if (txtAllocated)
free(txt);

height = 422;
Expand Down
6 changes: 4 additions & 2 deletions src/FSPathView.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ void FSSetPathViewMaxVisibleColumns(FSPathView* pvPtr, int columns)
int curMaxVisibleColumns;
int newFirstVisibleColumn = 0;

assert((int)pvPtr);
assert(pvPtr);

columns = (columns < MIN_VISIBLE_COLUMNS) ? MIN_VISIBLE_COLUMNS : columns;
columns = (columns > MAX_VISIBLE_COLUMNS) ? MAX_VISIBLE_COLUMNS : columns;
Expand Down Expand Up @@ -262,7 +262,7 @@ removeColumn(FSPathView* pvPtr, int column)
FSFileButton** clist;
char** tlist;

assert((int)pvPtr);
assert(pvPtr);

column = (column < 0) ? 0 : column;
if (column >= pvPtr->columnCount) {
Expand Down Expand Up @@ -452,6 +452,8 @@ scrollCallback(WMWidget* scroller, void* self)

} break;

case WSDecrementWheel:
case WSIncrementWheel:
case WSKnobSlot:
case WSNoPart:
/* do nothing */
Expand Down
5 changes: 2 additions & 3 deletions src/FSUtils.c
Original file line number Diff line number Diff line change
Expand Up @@ -575,9 +575,8 @@ void FSSetButtonImageFromFile(WMButton* btn, char* imgName)
}

if (imgName) {
WMColor* white = WMWhiteColor(WMWidgetScreen(btn));
pixmap = WMCreateBlendedPixmapFromFile(WMWidgetScreen(btn), imgName, white);
WMReleaseColor(white);
RColor white = { 0xff, 0xff, 0xff, 0xff };
pixmap = WMCreateBlendedPixmapFromFile(WMWidgetScreen(btn), imgName, &white);
} else {
pixmap = NULL;
}
Expand Down
2 changes: 1 addition & 1 deletion src/FSUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ WMPixmap* FSMakePixmap(WMScreen* sPtr, char** data, int width, int height);
void FSErrorDialog(char* title, char* msg);
int FSConfirmationDialog(char* title, char* msg);
mode_t FSGetUMask();
void FSUpdateFileView();
void FSUpdateFileView(FileAction action, FileInfo* src, FileInfo* dest);
char* FSGetHomeDir();
int FSStringMatch(char* pattern, char* fn);
WMPixmap* FSCreateBlendedPixmapFromFile(WMScreen* scr, char* fileName, WMColor* color);
Expand Down
3 changes: 2 additions & 1 deletion src/extnInspector.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "FSPanel.h"
#include "FSUtils.h"
#include "FSViewer.h"
#include <stdint.h>

#define WIDTH 272
#define HEIGHT 272
Expand Down Expand Up @@ -342,7 +343,7 @@ endedEditingObserver(void* observerData, WMNotification* notification)
{
Panel* panel = (Panel*)observerData;

if ((int)WMGetNotificationClientData(notification) == WMReturnTextMovement) {
if ((int)(intptr_t)WMGetNotificationClientData(notification) == WMReturnTextMovement) {
WMPerformButtonClick(panel->addBtn);
}
}
Expand Down
18 changes: 7 additions & 11 deletions src/magic.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ static int hdrbufsiz = 0; /* Size of header buffer. */
static struct stat stbuf; /* Stat buffer. */
static struct stat lstbuf; /* Lstat buffer. */
static int bytes; /* Bytes read from the file. */
static int mmatch();
static char* builtin_test();
static int mmatch(int i, char* buf);
static char* builtin_test(void);
static char* builtin_result;
static char* parse_string();
static char* parse_string(char** s);

void magic_parse_file(name) char* name;
void magic_parse_file(char* name)
{
FILE* fh;
int hsiz;
Expand Down Expand Up @@ -211,8 +211,7 @@ void magic_parse_file(name) char* name;
}
}

void magic_get_type(name, buf) char* name;
char* buf;
void magic_get_type(char* name, char* buf)
{
int i;
int fd;
Expand Down Expand Up @@ -273,9 +272,7 @@ char* buf;
strcpy(buf, builtin_test());
}

static int mmatch(i, buf)
int i;
char* buf;
static int mmatch(int i, char* buf)
{
int t;
int o;
Expand Down Expand Up @@ -424,8 +421,7 @@ static char* builtin_test()
return builtin_result = "unreadable";
}

static char* parse_string(s)
char** s;
static char* parse_string(char** s)
{
char cbuf[4];
int i;
Expand Down
2 changes: 1 addition & 1 deletion src/regexp/regerror.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <stdio.h>

void
regerror(s) char* s;
regerror(char* s)
{
fprintf(stderr, "regexp(3): %s", s);
}
Loading
Loading