1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-20 21:08:08 +01:00

Change to the linux kernel coding style

for arq in `git ls-files *.c`; do
    echo $arq;
    indent -linux -l115 $arq;
    done

The different line break at 115 columns is because
I use a widescreen monitor :-)
This commit is contained in:
Carlos R. Mafra
2009-08-20 00:59:40 +02:00
parent 59fc927dc9
commit 688a56e8ab
209 changed files with 87034 additions and 98138 deletions

View File

@@ -21,7 +21,6 @@
#include <config.h>
#include <X11/Xlib.h>
#include <stdlib.h>
#include <stdio.h>
@@ -29,152 +28,144 @@
#include "wraster.h"
static RImage*
load_graymap(char *file_name, FILE *file, int w, int h, int max, int raw)
static RImage *load_graymap(char *file_name, FILE * file, int w, int h, int max, int raw)
{
RImage *image;
RImage *image;
image = RCreateImage(w, h, 0);
if (!image) {
return NULL;
}
if (!raw) {
image = RCreateImage(w, h, 0);
if (!image) {
return NULL;
}
if (!raw) {
} else {
if (max<256) {
unsigned char *ptr;
char *buf;
int x, y;
} else {
if (max < 256) {
unsigned char *ptr;
char *buf;
int x, y;
buf = malloc(w+1);
if (!buf) {
return NULL;
}
buf = malloc(w + 1);
if (!buf) {
return NULL;
}
ptr = image->data;
for (y = 0; y < h; y++) {
if (!fread(buf, w, 1, file)) {
free(buf);
goto short_file;
}
for (x = 0; x < w; x++) {
*(ptr++) = buf[x];
*(ptr++) = buf[x];
*(ptr++) = buf[x];
}
}
free(buf);
} else {
ptr = image->data;
for (y = 0; y < h; y++) {
if (!fread(buf, w, 1, file)) {
free(buf);
goto short_file;
}
for (x = 0; x < w; x++) {
*(ptr++) = buf[x];
*(ptr++) = buf[x];
*(ptr++) = buf[x];
}
}
free(buf);
} else {
}
}
}
}
return image;
return image;
short_file:
RErrorCode = RERR_BADIMAGEFILE;
return NULL;
short_file:
RErrorCode = RERR_BADIMAGEFILE;
return NULL;
}
static RImage*
load_pixmap(char *file_name, FILE *file, int w, int h, int max, int raw)
static RImage *load_pixmap(char *file_name, FILE * file, int w, int h, int max, int raw)
{
RImage *image;
int i;
char buf[3];
unsigned char *ptr;
RImage *image;
int i;
char buf[3];
unsigned char *ptr;
image = RCreateImage(w, h, 0);
if (!image) {
return NULL;
}
ptr = image->data;
if (!raw) {
image = RCreateImage(w, h, 0);
if (!image) {
return NULL;
}
ptr = image->data;
if (!raw) {
} else {
if (max<256) {
i = 0;
while (i < w*h) {
if (fread(buf, 1, 3, file)!=3)
goto short_file;
*(ptr++) = buf[0];
*(ptr++) = buf[1];
*(ptr++) = buf[2];
i++;
}
} else {
} else {
if (max < 256) {
i = 0;
while (i < w * h) {
if (fread(buf, 1, 3, file) != 3)
goto short_file;
*(ptr++) = buf[0];
*(ptr++) = buf[1];
*(ptr++) = buf[2];
i++;
}
} else {
}
}
}
}
return image;
return image;
short_file:
RErrorCode = RERR_BADIMAGEFILE;
return NULL;
short_file:
RErrorCode = RERR_BADIMAGEFILE;
return NULL;
}
RImage*
RLoadPPM(RContext *context, char *file_name, int index)
RImage *RLoadPPM(RContext * context, char *file_name, int index)
{
FILE *file;
RImage *image = NULL;
char buffer[256];
int w, h, m;
int type;
FILE *file;
RImage *image = NULL;
char buffer[256];
int w, h, m;
int type;
#define GETL() if (!fgets(buffer, 255, file)) goto short_file
file = fopen(file_name, "rb");
if (!file) {
RErrorCode = RERR_OPEN;
return NULL;
}
file = fopen(file_name, "rb");
if (!file) {
RErrorCode = RERR_OPEN;
return NULL;
}
/* get signature */
GETL();
/* get signature */
GETL();
/* only accept raw pixmaps or graymaps */
if (buffer[0] != 'P' || (buffer[1] != '5' && buffer[1] != '6')) {
RErrorCode = RERR_BADFORMAT;
fclose(file);
return NULL;
}
/* only accept raw pixmaps or graymaps */
if (buffer[0] != 'P' || (buffer[1] != '5' && buffer[1] != '6')) {
RErrorCode = RERR_BADFORMAT;
fclose(file);
return NULL;
}
type = buffer[1];
type = buffer[1];
/* skip comments */
while (1) {
GETL();
/* skip comments */
while (1) {
GETL();
if (buffer[0]!='#')
break;
}
if (buffer[0] != '#')
break;
}
/* get size */
if (sscanf(buffer, "%i %i", &w, &h)!=2 || w < 1 || h < 1)
goto bad_file;
/* get size */
if (sscanf(buffer, "%i %i", &w, &h) != 2 || w < 1 || h < 1)
goto bad_file;
GETL();
if (sscanf(buffer, "%i", &m) != 1 || m < 1)
goto bad_file;
GETL();
if (sscanf(buffer, "%i", &m)!=1 || m < 1)
goto bad_file;
if (type == '5')
image = load_graymap(file_name, file, w, h, m, type == '5');
else if (type == '6')
image = load_pixmap(file_name, file, w, h, m, type == '6');
if (type=='5')
image = load_graymap(file_name, file, w, h, m, type=='5');
else if (type=='6')
image = load_pixmap(file_name, file, w, h, m, type=='6');
fclose(file);
return image;
fclose(file);
return image;
bad_file:
short_file:
RErrorCode = RERR_BADIMAGEFILE;
fclose(file);
return NULL;
bad_file:
short_file:
RErrorCode = RERR_BADIMAGEFILE;
fclose(file);
return NULL;
}