Skip to content

Commit

Permalink
fix segfault on error bug #3
Browse files Browse the repository at this point in the history
  • Loading branch information
PaperFanz committed Oct 15, 2019
1 parent de33e19 commit f304cef
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 12 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
*.o
laser
laser-*
*.exe
*.ifp
*.zip

# ignore test files
*.txt
Expand Down
2 changes: 1 addition & 1 deletion src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ SHELL = /bin/sh
IDIR = ../include
ODIR = obj

CC = clang
CC = gcc
CFLAGS = -I $(IDIR)

_DEPS = laser.h token.h
Expand Down
2 changes: 1 addition & 1 deletion src/flag.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const char *about = "Laser- a command line utility to assemble LC3 assembly code
"\tYou should have received a copy of the GNU General Public License\n"
"\talong with Laser. If not, see <https://www.gnu.org/licenses/>.\n";

const char *version_num = "2.0.0";
const char *version_num = "2.0.1";

const char *usage = "Laser- a command line utility to assemble LC3 assembly code\n\n"
"Usage:\n"
Expand Down
24 changes: 14 additions & 10 deletions src/notify.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,13 @@ void endlog (void)
void setcurrentfile (char *file)
{
// strip directories from filename string
char *ret = NULL;
#ifdef _WIN32
char *ret;
#if defined(_WIN32) || defined(_WIN64)
ret = strrchr (file, '\\') + 1;
#endif
#ifdef _WIN64
ret = strrchr (file, '\\') + 1;
#endif
#ifdef linux
#else
ret = strrchr (file, '/') + 1;
#endif
if (ret) file = ret;
#endif
if (ret > file) file = ret;
CURRENT_FILE = file;
}

Expand Down Expand Up @@ -123,7 +119,11 @@ void warning (uint32_t ln, const char *format, ...)

if (!NO_WARNINGS) {
va_start (strs, format);
#if defined(_WIN32) || defined(_WIN64)
printf ("Warning (%s line %d): ", CURRENT_FILE, ln);
#else
printf ("\033[01;33mWarning (%s line %d):\033[0m ", CURRENT_FILE, ln);
#endif
vprintf (format, strs);
printf("\n");
va_end (strs);
Expand All @@ -147,7 +147,11 @@ void error (uint32_t ln, const char *format, ...)

if (!NO_ERRORS) {
va_start (strs, format);
#ifdef _WIN32
printf ("Error (%s line %d): ", CURRENT_FILE, ln);
#else
printf ("\033[1;31mError (%s line %d):\033[0m ", CURRENT_FILE, ln);
#endif
vprintf (format, strs);
printf("\n");
va_end (strs);
Expand All @@ -160,4 +164,4 @@ void error (uint32_t ln, const char *format, ...)
fprintf(CURRENT_LOG, "\n");
va_end (strscpy);
}
}
}

0 comments on commit f304cef

Please sign in to comment.