[hackers] [sbase] whoops, add strnum.c || Connor Lane Smith

From: <hg_AT_suckless.org>
Date: Fri, 10 Jun 2011 06:46:26 +0200 (CEST)

changeset: 73:b3bacb1dcc87
tag: tip
user: Connor Lane Smith <cls_AT_lubutu.com>
date: Fri Jun 10 05:46:20 2011 +0100
files: util/strnum.c
description:
whoops, add strnum.c

diff -r 43a3e68f76e5 -r b3bacb1dcc87 util/strnum.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/util/strnum.c Fri Jun 10 05:46:20 2011 +0100
@@ -0,0 +1,20 @@
+/* See LICENSE file for copyright and license details. */
+#include <stdio.h>
+#include <stdlib.h>
+#include "../util.h"
+
+long
+strnum(const char *s, int base)
+{
+ char *end;
+ long n;
+
+ n = strtol(s, &end, base);
+ if(*end != '\0') {
+ if(base == 0)
+ eprintf("%s: not a number\n", s);
+ else
+ eprintf("%s: not a base %d number\n", s, base);
+ }
+ return n;
+}
Received on Fri Jun 10 2011 - 06:46:26 CEST

This archive was generated by hypermail 2.2.0 : Fri Jun 10 2011 - 06:48:06 CEST