Unix Technical Forum

Re: floating point exception in games/boggle/mkdict (+ typo)

This is a discussion on Re: floating point exception in games/boggle/mkdict (+ typo) within the lucky.openbsd.tech forums, part of the OpenBSD category; --> Hi again, I have used some unneeded curly brackets, this diff also writes both if-statements into one: --- games/boggle/mkdict/mkdict.c~ ...


Go Back   Unix Technical Forum > Unix Operating Systems > OpenBSD > lucky.openbsd.tech

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-22-2008, 01:17 PM
Tobias Stoeckmann
 
Posts: n/a
Default Re: floating point exception in games/boggle/mkdict (+ typo)

Hi again,

I have used some unneeded curly brackets, this diff also writes both
if-statements into one:

--- games/boggle/mkdict/mkdict.c~ Sun Apr 2 12:13:55 2006
+++ games/boggle/mkdict/mkdict.c Sun Apr 2 12:14:36 2006
@@ -51,12 +51,13 @@
* Filter out words that:
* 1) Are not completely made up of lower case letters
* 2) Contain a 'q' not immediately followed by a 'u'
- * 3) Are less that 3 characters long
+ * 3) Are less than 3 characters long
* 4) Are greater than MAXWORDLEN characters long
*/

#include <ctype.h>
#include <err.h>
+#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -74,8 +75,8 @@
prev = 0;
current = 1;
buf[prev][0] = '\0';
- if (argc == 2)
- n = atoi(argv[1]);
+ if (argc == 2 && (n = strtonum(argv[1], 1, INT_MAX, NULL)) == 0)
+ errx(1, "invalid value");

for (nwords = 1;
fgets(buf[current], MAXWORDLEN + 1, stdin) != NULL; ++nwords) {


Tobias Stoeckmann

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 04:30 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com