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 836a5643d7e9f2cf387d9a2528979aa071fd4dd8 (commit)
via b3a6cc8de7aca95a252f7c2e88cb3079b6b8bd9a (commit)
via e06b3005e833d4c34f9b5671daa0cc44f4f9ea52 (commit)
via e4d0ea5373762b4fe85e4629fbf9959763089150 (commit)
via 7e4a3ae57f491e53fd9ef4a3aea9c0193a33cc74 (commit)
via 89bf2634105574e6e90f5a363b54ae92f092dc65 (commit)
via 7a180b0ef8db7b12c662fb6630975f41e3c921b0 (commit)
via 14643408e8b1acfc32668de5e1f7263351a24480 (commit)
from 6bf5f947a9c30e7f67ba761404e040de582ea8d1 (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/836a5643d7e9f2cf387d9a2528979aa071fd4dd8
commit 836a5643d7e9f2cf387d9a2528979aa071fd4dd8
Author: Carlos R. Mafra <[email protected]>
Date: Sun Jan 15 23:27:15 2012 +0000
configure: Also display the library dir in the summary
The summary now looks like:
Window Maker was configured as follows:
Installation path prefix : /usr/local
Installation path for binaries : /usr/local/bin
Installation path for libraries : /usr/lib64
Installation path for WPrefs.app : /usr/local
Supported graphic format libraries : XPM PNG JPEG TIFF builtin-PPM
Antialiased text support in WINGs : yes
Xinerama extension support : yes
XRandR extension support : yes
Translated message files to install : None
I want to see the library line in order to avoid forgetting that
I should put them in /usr/lib64 (and not in the defaul /usr/local/lib)
diff --git a/configure.ac b/configure.ac
index e358d95..15e6043 100644
--- a/configure.ac
+++ b/configure.ac
@@ -914,6 +914,7 @@ echo "Window Maker was configured as follows:"
echo
echo "Installation path prefix : $prefix"
echo "Installation path for binaries : $_bindir"
+echo "Installation path for libraries : $libdir"
echo "Installation path for WPrefs.app : $wprefs_base_dir" | sed -e
's|${prefix}|'"$prefix|"
echo "Supported graphic format libraries : $supported_gfx"
echo "Antialiased text support in WINGs : $xft"
http://repo.or.cz/w/wmaker-crm.git/commit/b3a6cc8de7aca95a252f7c2e88cb3079b6b8bd9a
commit b3a6cc8de7aca95a252f7c2e88cb3079b6b8bd9a
Author: Christophe CURIS <[email protected]>
Date: Sun Jan 15 20:45:54 2012 +0100
wrlib: Improvement in the alpha channel support.
There are some problems in the alpha channel support, as is
reported at http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=72917
This patch add a new RCombineAlpha function, based on Gimp. This
function is called when needed in the raster.c functions.
This patch is based on the Brad Jorsch <[email protected]>
patch for the 0.62.1-0.1 version.
[crmafra: v1 was sent by Rodolfo kix Garcia <[email protected]>]
diff --git a/wrlib/Makefile.am b/wrlib/Makefile.am
index 6c6de3d..8dec1f6 100644
--- a/wrlib/Makefile.am
+++ b/wrlib/Makefile.am
@@ -20,6 +20,7 @@ include_HEADERS = wraster.h
libwraster_la_SOURCES = raster.c + alpha_combine.c
draw.c color.c load.c diff
--git a/wrlib/alpha_combine.c b/wrlib/alpha_combine.c
new file mode 100644
index 0000000..967c1f6
--- /dev/null
+++ b/wrlib/alpha_combine.c
@@ -0,0 +1,68 @@
+/* alpha_combine.c - Alpha channel combination, based on Gimp 1.1.24
+ *
+ * Raster graphics library
+ *
+ * Copyright (c) 1997-2003 Alfredo K. Kojima
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include "wraster.h"
+
+void RCombineAlpha(unsigned char *d, unsigned char *s, int s_has_alpha,
+ int width, int height, int dwi, int swi, int opacity) {
+ int x, y;
+ int t, sa;
+ int alpha;
+ float ratio, cratio;
+
+ for (y=0; y<height; y++) {
+ for (x=0; x<width; x++) {
+ sa=s_has_alpha?*(s+3):255;
+
+ if (opacity!=255) {
+ t = sa * opacity + 0x80;
+ sa = ((t>>8)+t)>>8;
+ }
+
+ t = *(d+3) * (255-sa) + 0x80;
+ alpha = sa + (((t>>8)+t)>>8);
+
+ if (sa==0 || alpha==0) {
+ ratio = 0;
+ cratio = 1.0;
+ } else if(sa == alpha) {
+ ratio = 1.0;
+ cratio = 0;
+ } else {
+ ratio = (float)sa / alpha;
+ cratio = 1.0 - ratio;
+ }
+
+ *d = (int)*d * cratio + (int)*s * ratio;
+ s++; d++;
+ *d = (int)*d * cratio + (int)*s * ratio;
+ s++; d++;
+ *d = (int)*d * cratio + (int)*s * ratio;
+ s++; d++;
+ *d = alpha;
+ d++;
+
+ if (s_has_alpha) s++;
+ }
+ d+=dwi;
+ s+=swi;
+ }
+}
diff --git a/wrlib/draw.c b/wrlib/draw.c
index 87f2cad..071f016 100644
--- a/wrlib/draw.c
+++ b/wrlib/draw.c
@@ -143,6 +143,7 @@ static void operatePixel(RImage * image, int ofs, int
operation, RColor * color)
*sr = (((int)*sr * nalpha) + ((int)color->red * alpha))
/ 256;
*sg = (((int)*sg * nalpha) + ((int)color->green *
alpha)) / 256;
*sb = (((int)*sb * nalpha) + ((int)color->blue *
alpha)) / 256;
+ *sa = alpha + ((int)*sa * nalpha) / 256;
}
break;
case RAddOperation:
diff --git a/wrlib/raster.c b/wrlib/raster.c
index 188dd51..f01db84 100644
--- a/wrlib/raster.c
+++ b/wrlib/raster.c
@@ -171,7 +171,7 @@ void RCombineImages(RImage * image, RImage * src)
*d++ = *s++;
*d++ = *s++;
*d++ = *s++;
- d++;
+ *d++ = 255;
}
}
}
@@ -200,20 +200,7 @@ void RCombineImages(RImage * image, RImage * src)
s++;
}
} else {
- for (i = 0; i < image->height * image->width; i++) {
- alpha = *(s + 3);
- calpha = 255 - alpha;
- *d = (((int)*d * calpha) + ((int)*s * alpha)) /
256;
- d++;
- s++;
- *d = (((int)*d * calpha) + ((int)*s * alpha)) /
256;
- d++;
- s++;
- *d = (((int)*d * calpha) + ((int)*s * alpha)) /
256;
- d++;
- s++;
- *d++ |= *s++;
- }
+ RCombineAlpha(d, s, 1, image->width, image->height, 0,
0, 255);
}
}
}
@@ -237,39 +224,25 @@ void RCombineImagesWithOpaqueness(RImage * image, RImage
* src, int opaqueness)
#define COP c_opaqueness
if (!HAS_ALPHA(src)) {
- int dalpha = HAS_ALPHA(image);
- for (i = 0; i < image->width * image->height; i++) {
- *d = (((int)*d * (int)COP) + ((int)*s * (int)OP)) / 256;
- d++;
- s++;
- *d = (((int)*d * (int)COP) + ((int)*s * (int)OP)) / 256;
- d++;
- s++;
- *d = (((int)*d * (int)COP) + ((int)*s * (int)OP)) / 256;
- d++;
- s++;
- if (dalpha) {
- d++;
- }
- }
- } else {
- int tmp;
-
if (!HAS_ALPHA(image)) {
for (i = 0; i < image->width * image->height; i++) {
- tmp = (*(s + 3) * opaqueness) / 256;
- *d = (((int)*d * (255 - tmp)) + ((int)*s *
tmp)) / 256;
+ *d = (((int)*d * (int)COP) + ((int)*s *
(int)OP)) / 256;
d++;
s++;
- *d = (((int)*d * (255 - tmp)) + ((int)*s *
tmp)) / 256;
+ *d = (((int)*d * (int)COP) + ((int)*s *
(int)OP)) / 256;
d++;
s++;
- *d = (((int)*d * (255 - tmp)) + ((int)*s *
tmp)) / 256;
+ *d = (((int)*d * (int)COP) + ((int)*s *
(int)OP)) / 256;
d++;
s++;
- s++;
}
} else {
+ RCombineAlpha(d, s, 0, image->width, image->height, 0,
0, OP);
+ }
+ } else {
+ int tmp;
+
+ if (!HAS_ALPHA(image)) {
for (i = 0; i < image->width * image->height; i++) {
tmp = (*(s + 3) * opaqueness) / 256;
*d = (((int)*d * (255 - tmp)) + ((int)*s *
tmp)) / 256;
@@ -281,10 +254,10 @@ void RCombineImagesWithOpaqueness(RImage * image, RImage
* src, int opaqueness)
*d = (((int)*d * (255 - tmp)) + ((int)*s *
tmp)) / 256;
d++;
s++;
- *d |= tmp;
- d++;
s++;
}
+ } else {
+ RCombineAlpha(d, s, 1, image->width, image->height, 0,
0, opaqueness);
}
}
#undef OP
@@ -360,7 +333,7 @@ void RCombineArea(RImage * image, RImage * src, int sx, int
sy, unsigned width,
*d++ = *s++;
*d++ = *s++;
*d++ = *s++;
- d++;
+ *d++ = 255;
}
d += dwi;
s += swi;
@@ -379,25 +352,27 @@ void RCombineArea(RImage * image, RImage * src, int sx,
int sy, unsigned width,
d = image->data + (dy * (int)image->width + dx) * 3;
}
- for (y = 0; y < height; y++) {
- for (x = 0; x < width; x++) {
- alpha = *(s + 3);
- calpha = 255 - alpha;
- *d = (((int)*d * calpha) + ((int)*s * alpha)) /
256;
- s++;
- d++;
- *d = (((int)*d * calpha) + ((int)*s * alpha)) /
256;
- s++;
- d++;
- *d = (((int)*d * calpha) + ((int)*s * alpha)) /
256;
- s++;
- d++;
- s++;
- if (dalpha)
+ if (!dalpha) {
+ for (y = 0; y < height; y++) {
+ for (x = 0; x < width; x++) {
+ alpha = *(s + 3);
+ calpha = 255 - alpha;
+ *d = (((int)*d * calpha) + ((int)*s *
alpha)) / 256;
+ s++;
d++;
+ *d = (((int)*d * calpha) + ((int)*s *
alpha)) / 256;
+ s++;
+ d++;
+ *d = (((int)*d * calpha) + ((int)*s *
alpha)) / 256;
+ s++;
+ d++;
+ s++;
+ }
+ d += dwi;
+ s += swi;
}
- d += dwi;
- s += swi;
+ } else {
+ RCombineAlpha(d, s, 1, width, height, dwi, swi, 255);
}
}
}
@@ -502,22 +477,24 @@ RCombineAreaWithOpaqueness(RImage * image, RImage * src,
int sx, int sy,
s = src->data + (sy * src->width + sx) * 3;
swi = (src->width - width) * 3;
- for (y = 0; y < height; y++) {
- for (x = 0; x < width; x++) {
- *d = (((int)*d * (int)COP) + ((int)*s *
(int)OP)) / 256;
- s++;
- d++;
- *d = (((int)*d * (int)COP) + ((int)*s *
(int)OP)) / 256;
- s++;
- d++;
- *d = (((int)*d * (int)COP) + ((int)*s *
(int)OP)) / 256;
- s++;
- d++;
- if (dalpha)
+ if (!dalpha) {
+ for (y = 0; y < height; y++) {
+ for (x = 0; x < width; x++) {
+ *d = (((int)*d * (int)COP) + ((int)*s *
(int)OP)) / 256;
+ s++;
d++;
+ *d = (((int)*d * (int)COP) + ((int)*s *
(int)OP)) / 256;
+ s++;
+ d++;
+ *d = (((int)*d * (int)COP) + ((int)*s *
(int)OP)) / 256;
+ s++;
+ d++;
+ }
+ d += dwi;
+ s += swi;
}
- d += dwi;
- s += swi;
+ } else {
+ RCombineAlpha(d, s, 0, width, height, dwi, swi, OP);
}
} else {
int tmp;
@@ -525,24 +502,26 @@ RCombineAreaWithOpaqueness(RImage * image, RImage * src,
int sx, int sy,
s = src->data + (sy * src->width + sx) * 4;
swi = (src->width - width) * 4;
- for (y = 0; y < height; y++) {
- for (x = 0; x < width; x++) {
- tmp = (*(s + 3) * opaqueness) / 256;
- *d = (((int)*d * (255 - tmp)) + ((int)*s *
tmp)) / 256;
- d++;
- s++;
- *d = (((int)*d * (255 - tmp)) + ((int)*s *
tmp)) / 256;
- d++;
- s++;
- *d = (((int)*d * (255 - tmp)) + ((int)*s *
tmp)) / 256;
- d++;
- s++;
- s++;
- if (dalpha)
+ if (!dalpha) {
+ for (y = 0; y < height; y++) {
+ for (x = 0; x < width; x++) {
+ tmp = (*(s + 3) * opaqueness) / 256;
+ *d = (((int)*d * (255 - tmp)) +
((int)*s * tmp)) / 256;
+ d++;
+ s++;
+ *d = (((int)*d * (255 - tmp)) +
((int)*s * tmp)) / 256;
+ d++;
+ s++;
+ *d = (((int)*d * (255 - tmp)) +
((int)*s * tmp)) / 256;
d++;
+ s++;
+ s++;
+ }
+ d += dwi;
+ s += swi;
}
- d += dwi;
- s += swi;
+ } else {
+ RCombineAlpha(d, s, 1, width, height, dwi, swi, OP);
}
}
#undef OP
@@ -627,12 +606,12 @@ RImage *RMakeCenteredImage(RImage * image, unsigned
width, unsigned height, RCol
int x, y, w, h, sx, sy;
RImage *tmp;
- tmp = RCreateImage(width, height, False);
+ tmp = RCreateImage(width, height, HAS_ALPHA(image));
if (!tmp) {
return NULL;
}
- RClearImage(tmp, color);
+ RFillImage(tmp, color);
if (image->height < height) {
h = image->height;
diff --git a/wrlib/wraster.h b/wrlib/wraster.h
index 78bfc16..b55af32 100644
--- a/wrlib/wraster.h
+++ b/wrlib/wraster.h
@@ -356,6 +356,9 @@ void RCombineAreaWithOpaqueness(RImage *image, RImage *src,
int sx, int sy,
unsigned width, unsigned height, int dx, int
dy,
int opaqueness);
+void RCombineAlpha(unsigned char *d, unsigned char *s, int s_has_alpha,
+ int width, int height, int dwi, int swi, int opacity);
+
RImage *RScaleImage(RImage *image, unsigned new_width, unsigned new_height);
RImage *RSmoothScaleImage(RImage *src, unsigned new_width,
http://repo.or.cz/w/wmaker-crm.git/commit/e06b3005e833d4c34f9b5671daa0cc44f4f9ea52
commit e06b3005e833d4c34f9b5671daa0cc44f4f9ea52
Author: Carlos R. Mafra <[email protected]>
Date: Sun Jan 15 14:17:27 2012 +0000
getstyle: Remove dead code
The statement under "if (style_file)" in the else branch of
"if (make_pack)" will never be executed because getstyle already
prints out a help message and exits before that.
So remove that code.
diff --git a/util/getstyle.c b/util/getstyle.c
index 7b74039..a988946 100644
--- a/util/getstyle.c
+++ b/util/getstyle.c
@@ -401,11 +401,7 @@ int main(int argc, char **argv)
WMWritePropListToFile(style, path);
wfree(path);
} else {
- if (style_file) {
- WMWritePropListToFile(style, style_file);
- } else {
- puts(WMGetPropListDescription(style, True));
- }
+ puts(WMGetPropListDescription(style, True));
}
return 0;
}
http://repo.or.cz/w/wmaker-crm.git/commit/e4d0ea5373762b4fe85e4629fbf9959763089150
commit e4d0ea5373762b4fe85e4629fbf9959763089150
Author: Carlos R. Mafra <[email protected]>
Date: Sun Jan 15 13:22:18 2012 +0000
getstyle: Get rid of abortar()
Instead of using a temporary buffer to store a "reason" string
which is later printf()'ed by abortar(), use wwarning() directly
and do the small cleanup done by abortar() on the spot.
As this was the only call site for abortar() it can now be removed.
The resulting object code gets smaller as a side effect.
Thanks to Christophe <[email protected]> for finding a mistake
in the first version of this patch.
diff --git a/util/getstyle.c b/util/getstyle.c
index 3932962..7b74039 100644
--- a/util/getstyle.c
+++ b/util/getstyle.c
@@ -148,16 +148,6 @@ void print_help(int print_usage, int exitval)
exit(exitval);
}
-void abortar(char *reason)
-{
- printf("%s: %sn", __progname, reason);
- if (ThemePath) {
- printf("Removing unfinished theme packn");
- (void)wrmdirhier(ThemePath);
- }
- exit(1);
-}
-
static Bool isFontOption(char *option)
{
int i;
@@ -177,10 +167,9 @@ void findCopyFile(char *dir, char *file)
fullPath = wfindfileinarray(PixmapPath, file);
if (!fullPath) {
- char buffer[4000];
-
- sprintf(buffer, "could not find file %s", file);
- abortar(buffer);
+ wwarning("Could not find file %s", file);
+ if (ThemePath)
+ (void)wrmdirhier(ThemePath);
}
copy_file(dir, fullPath, fullPath);
free(fullPath);
http://repo.or.cz/w/wmaker-crm.git/commit/7e4a3ae57f491e53fd9ef4a3aea9c0193a33cc74
commit 7e4a3ae57f491e53fd9ef4a3aea9c0193a33cc74
Author: Carlos R. Mafra <[email protected]>
Date: Sun Jan 15 06:09:41 2012 +0000
getstyle: Use new copy_file() from libWUtil and delete copyFile()
Now both getstyle.c and wcolorpanel.c use the same copy_file() function
from libWUtil, and their similar private copies are gone.
diff --git a/util/getstyle.c b/util/getstyle.c
index 624c0e6..3932962 100644
--- a/util/getstyle.c
+++ b/util/getstyle.c
@@ -171,72 +171,6 @@ static Bool isFontOption(char *option)
return False;
}
-/*
- * copy a file specified by `file' into `directory'. name stays.
- */
-/*
- * it is more or less assumed that this function will only
- * copy reasonably-sized files
- */
-/* XXX: is almost like WINGs/wcolodpanel.c:fetchFile() */
-void copyFile(char *dir, char *file)
-{
- FILE *src = NULL, *dst = NULL;
- size_t nread, nwritten, len;
- char buf[4096];
- struct stat st;
- char *dstpath;
-
- /* only to a directory */
- if (stat(dir, &st) != 0 || !S_ISDIR(st.st_mode))
- return;
- /* only copy files */
- if (stat(file, &st) != 0 || !S_ISREG(st.st_mode))
- return;
-
- len = strlen(dir) + 1 /* / */ + strlen(file) + 1 /* '0' */;
- dstpath = wmalloc(len);
- snprintf(dstpath, len, "%s/%s", dir, basename(file));
- buf[len] = '0';
-
- RETRY( dst = fopen(dstpath, "wb") )
- if (dst == NULL) {
- werror(_("Could not create %s"), dstpath);
- goto err;
- }
-
- RETRY( src = fopen(file, "rb") )
- if (src == NULL) {
- werror(_("Could not open %s"), file);
- goto err;
- }
-
- do {
- RETRY( nread = fread(buf, 1, sizeof(buf), src) )
- if (ferror(src))
- break;
-
- RETRY( nwritten = fwrite(buf, 1, nread, dst) )
- if (ferror(dst) || feof(src) || nread != nwritten)
- break;
-
- } while (1);
-
- if (ferror(src) || ferror(dst))
- unlink(dstpath);
-
- fchmod(fileno(dst), st.st_mode);
- fsync(fileno(dst));
- RETRY( fclose(dst) )
-
-err:
- if (src) {
- RETRY( fclose(src) )
- }
- wfree(dstpath);
- return;
-}
-
void findCopyFile(char *dir, char *file)
{
char *fullPath;
@@ -248,7 +182,7 @@ void findCopyFile(char *dir, char *file)
sprintf(buffer, "could not find file %s", file);
abortar(buffer);
}
- copyFile(dir, fullPath);
+ copy_file(dir, fullPath, fullPath);
free(fullPath);
}
@@ -304,7 +238,7 @@ void makeThemePack(WMPropList * style, char *themeName)
p = strrchr(WMGetFromPLString(file), '/');
if (p) {
- copyFile(themeDir,
WMGetFromPLString(file));
+ copy_file(themeDir,
WMGetFromPLString(file), WMGetFromPLString(file));
newPath = wstrdup(p + 1);
WMDeleteFromPLArray(value, 1);
@@ -323,7 +257,7 @@ void makeThemePack(WMPropList * style, char *themeName)
p = strrchr(WMGetFromPLString(file), '/');
if (p) {
- copyFile(themeDir,
WMGetFromPLString(file));
+ copy_file(themeDir,
WMGetFromPLString(file), WMGetFromPLString(file));
newPath = wstrdup(p + 1);
WMDeleteFromPLArray(value, 1);
@@ -337,7 +271,7 @@ void makeThemePack(WMPropList * style, char *themeName)
p = strrchr(WMGetFromPLString(file), '/');
if (p) {
- copyFile(themeDir,
WMGetFromPLString(file));
+ copy_file(themeDir,
WMGetFromPLString(file), WMGetFromPLString(file));
newPath = wstrdup(p + 1);
WMDeleteFromPLArray(value, 2);
http://repo.or.cz/w/wmaker-crm.git/commit/89bf2634105574e6e90f5a363b54ae92f092dc65
commit 89bf2634105574e6e90f5a363b54ae92f092dc65
Author: Carlos R. Mafra <[email protected]>
Date: Sun Jan 15 05:58:06 2012 +0000
WINGs: Replace fetchFile() by copy_file() in wcolorpanel.c
Now that copy_file() is in libWUtil, use it instead of fetchFile(),
which can be removed from wcolorpanel.c.
diff --git a/WINGs/wcolorpanel.c b/WINGs/wcolorpanel.c
index eb01947..03e8223 100644
--- a/WINGs/wcolorpanel.c
+++ b/WINGs/wcolorpanel.c
@@ -275,7 +275,6 @@ enum {
#define M_PI 3.14159265358979323846
#endif
-static int fetchFile(char *toPath, char *imageSrcFile, char
*imageDestFileName);
char *generateNewFilename(char *curName);
void convertCPColor(CPColor * color);
RColor ulongToRColor(WMScreen * scr, unsigned long value);
@@ -2925,7 +2924,7 @@ static void customPaletteMenuNewFromFile(W_ColorPanel *
panel)
/* Copy image to $(gnustepdir)/Library/Colors/ &
* Add filename to history menu */
- if (fetchFile(panel->configurationPath, filepath, filename) ==
0) {
+ if (copy_file(panel->configurationPath, filepath, filename) ==
0) {
/* filepath is a "local" path now the file has been
copied */
wfree(filepath);
@@ -3337,59 +3336,6 @@ static void hsbInit(W_ColorPanel * panel)
/************************** Common utility functions ************************/
-static int fetchFile(char *toPath, char *srcFile, char *destFile)
-{
- FILE *src, *dst;
- size_t nread, nwritten;
- char *dstpath;
- struct stat st;
- char buf[BUFSIZE];
-
- /* only to a directory */
- if (stat(toPath, &st) != 0 || !S_ISDIR(st.st_mode))
- return -1;
- /* only copy files */
- if (stat(srcFile, &st) != 0 || !S_ISREG(st.st_mode))
- return -1;
-
- RETRY( src = fopen(srcFile, "rb") )
- if (src == NULL) {
- werror(_("Could not open %s"), srcFile);
- return -1;
- }
-
- dstpath = wstrconcat(toPath, destFile);
- RETRY( dst = fopen(dstpath, "wb") )
- if (dst == NULL) {
- werror(_("Could not create %s"), dstpath);
- wfree(dstpath);
- RETRY( fclose(src) )
- return -1;
- }
-
- do {
- RETRY( nread = fread(buf, 1, sizeof(buf), src) )
- if (ferror(src))
- break;
-
- RETRY( nwritten = fwrite(buf, 1, nread, dst) )
- if (ferror(dst) || feof(src) || nread != nwritten)
- break;
-
- } while (1);
-
- if (ferror(src) || ferror(dst))
- unlink(dstpath);
-
- RETRY( fclose(src) )
- fchmod(fileno(dst), st.st_mode);
- fsync(fileno(dst));
- RETRY( fclose(dst) )
- wfree(dstpath);
-
- return 0;
-}
-
char *generateNewFilename(char *curName)
{
int n;
http://repo.or.cz/w/wmaker-crm.git/commit/7a180b0ef8db7b12c662fb6630975f41e3c921b0
commit 7a180b0ef8db7b12c662fb6630975f41e3c921b0
Author: Carlos R. Mafra <[email protected]>
Date: Sun Jan 15 05:54:34 2012 +0000
WINGs: Add copy_file() to libWUtil
This is essentially the fetchFile() from wcolorpanel.c from the last
commit, but renamed to a better name.
This patch just adds the function to the lib. Nobody uses it yet.
diff --git a/WINGs/WINGs/WUtil.h b/WINGs/WINGs/WUtil.h
index f3131c5..4872df5 100644
--- a/WINGs/WINGs/WUtil.h
+++ b/WINGs/WINGs/WUtil.h
@@ -201,6 +201,8 @@ char* wfindfileinarray(WMPropList* array, char *file);
char* wexpandpath(char *path);
+int copy_file(char *toPath, char *srcFile, char *destFile);
+
/* don't free the returned string */
char* wgethomedir(void);
diff --git a/WINGs/findfile.c b/WINGs/findfile.c
index 70d1e47..70493a5 100644
--- a/WINGs/findfile.c
+++ b/WINGs/findfile.c
@@ -22,7 +22,9 @@
#include "WUtil.h"
+#include <sys/stat.h>
#include <errno.h>
+#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
@@ -33,6 +35,8 @@
#define PATH_MAX 1024
#endif
+#define RETRY( x ) do { x; } while (errno == EINTR);
+
char *wgethomedir()
{
static char *home = NULL;
@@ -403,3 +407,56 @@ char *wfindfileinarray(WMPropList * array, char *file)
}
return NULL;
}
+
+int copy_file(char *dir, char *src_file, char *dest_file)
+{
+ FILE *src, *dst;
+ size_t nread, nwritten;
+ char *dstpath;
+ struct stat st;
+ char buf[4096];
+
+ /* only to a directory */
+ if (stat(dir, &st) != 0 || !S_ISDIR(st.st_mode))
+ return -1;
+ /* only copy files */
+ if (stat(src_file, &st) != 0 || !S_ISREG(st.st_mode))
+ return -1;
+
+ RETRY( src = fopen(src_file, "rb") )
+ if (src == NULL) {
+ werror(_("Could not open %s"), src_file);
+ return -1;
+ }
+
+ dstpath = wstrconcat(dir, dest_file);
+ RETRY( dst = fopen(dstpath, "wb") )
+ if (dst == NULL) {
+ werror(_("Could not create %s"), dstpath);
+ wfree(dstpath);
+ RETRY( fclose(src) )
+ return -1;
+ }
+
+ do {
+ RETRY( nread = fread(buf, 1, sizeof(buf), src) )
+ if (ferror(src))
+ break;
+
+ RETRY( nwritten = fwrite(buf, 1, nread, dst) )
+ if (ferror(dst) || feof(src) || nread != nwritten)
+ break;
+
+ } while (1);
+
+ if (ferror(src) || ferror(dst))
+ unlink(dstpath);
+
+ RETRY( fclose(src) )
+ fchmod(fileno(dst), st.st_mode);
+ fsync(fileno(dst));
+ RETRY( fclose(dst) )
+ wfree(dstpath);
+
+ return 0;
+}
http://repo.or.cz/w/wmaker-crm.git/commit/14643408e8b1acfc32668de5e1f7263351a24480
commit 14643408e8b1acfc32668de5e1f7263351a24480
Author: Carlos R. Mafra <[email protected]>
Date: Sun Jan 15 05:04:29 2012 +0000
WINGs: Make fetchFile() more similar to copyFile() from getstyle.c
The idea is to use the fetchFile() in getstyle.c and in wcolorpanel.c
instead of using two very similar functions.
In order to do that, let's move the most generic one (fetchFile()) to
libWUtils, and this is the first step.
diff --git a/WINGs/wcolorpanel.c b/WINGs/wcolorpanel.c
index c86dfdd..eb01947 100644
--- a/WINGs/wcolorpanel.c
+++ b/WINGs/wcolorpanel.c
@@ -3342,8 +3342,16 @@ static int fetchFile(char *toPath, char *srcFile, char
*destFile)
FILE *src, *dst;
size_t nread, nwritten;
char *dstpath;
+ struct stat st;
char buf[BUFSIZE];
+ /* only to a directory */
+ if (stat(toPath, &st) != 0 || !S_ISDIR(st.st_mode))
+ return -1;
+ /* only copy files */
+ if (stat(srcFile, &st) != 0 || !S_ISREG(st.st_mode))
+ return -1;
+
RETRY( src = fopen(srcFile, "rb") )
if (src == NULL) {
werror(_("Could not open %s"), srcFile);
@@ -3374,10 +3382,11 @@ static int fetchFile(char *toPath, char *srcFile, char
*destFile)
unlink(dstpath);
RETRY( fclose(src) )
+ fchmod(fileno(dst), st.st_mode);
fsync(fileno(dst));
RETRY( fclose(dst) )
-
wfree(dstpath);
+
return 0;
}
-----------------------------------------------------------------------
Summary of changes:
WINGs/WINGs/WUtil.h | 2 +
WINGs/findfile.c | 57 ++++++++++++++++++
WINGs/wcolorpanel.c | 47 +--------------
configure.ac | 1 +
util/getstyle.c | 97 +++---------------------------
wrlib/Makefile.am | 1 +
wrlib/alpha_combine.c | 68 +++++++++++++++++++++
wrlib/draw.c | 1 +
wrlib/raster.c | 159 +++++++++++++++++++++----------------------------
wrlib/wraster.h | 3 +
10 files changed, 211 insertions(+), 225 deletions(-)
create mode 100644 wrlib/alpha_combine.c
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 ("Fork from the last available CVS version of Window Maker")
--
To unsubscribe, send mail to [email protected].