Skip to content
Snippets Groups Projects
Commit 38d299c2 authored by Mike Frysinger's avatar Mike Frysinger Committed by Wolfgang Denk
Browse files

cleanup easylogo


- make the Makefile not suck
- include proper headers for prototypes
- fix obvious broken handling of strchr() when handling '.' in filenames

Signed-Off-By: default avatarMike Frysinger <vapier@gentoo.org>
parent 883e3925
No related branches found
No related tags found
No related merge requests found
all: easylogo.c CFLAGS += -Wall
gcc easylogo.c -o easylogo
all: easylogo
clean:
rm -f easylogo *.o
.PHONY: all clean
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
*/ */
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#pragma pack(1) #pragma pack(1)
...@@ -41,7 +43,7 @@ typedef struct { ...@@ -41,7 +43,7 @@ typedef struct {
} yuyv_t ; } yuyv_t ;
typedef struct { typedef struct {
unsigned char *data, void *data,
*palette ; *palette ;
int width, int width,
height, height,
...@@ -352,9 +354,10 @@ int main (int argc, char *argv[]) ...@@ -352,9 +354,10 @@ int main (int argc, char *argv[])
strcpy (varname, argv[2]); strcpy (varname, argv[2]);
else else
{ {
int pos = strchr(inputfile, '.'); char *dot = strchr(inputfile, '.');
int pos = dot - inputfile;
if (pos >= 0) if (dot)
{ {
strncpy (varname, inputfile, pos); strncpy (varname, inputfile, pos);
varname[pos] = 0 ; varname[pos] = 0 ;
...@@ -365,13 +368,15 @@ int main (int argc, char *argv[]) ...@@ -365,13 +368,15 @@ int main (int argc, char *argv[])
strcpy (outputfile, argv[3]); strcpy (outputfile, argv[3]);
else else
{ {
int pos = strchr (varname, '.'); char *dot = strchr (varname, '.');
int pos = dot - varname;
if (pos > 0) if (dot)
{ {
char app[DEF_FILELEN] ; char app[DEF_FILELEN] ;
strncpy(app, varname, pos); strncpy(app, varname, pos);
app[pos] = 0;
sprintf(outputfile, "%s.h", app); sprintf(outputfile, "%s.h", app);
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment