From 7214f6eb1e94583d30ec6474a1b308fdd6280250 Mon Sep 17 00:00:00 2001
From: kcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>
Date: Thu, 26 Dec 2002 09:46:04 +0000
Subject: use gcc's extension to check format string and make compiler happier

git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk@588 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
---
 pttbbs/include/proto.h | 14 ++++++++++----
 pttbbs/mbbsd/edit.c    |  5 +++--
 pttbbs/mbbsd/gamble.c  | 11 +++++------
 pttbbs/mbbsd/guess.c   | 14 +++++++-------
 pttbbs/mbbsd/user.c    |  4 ++--
 5 files changed, 27 insertions(+), 21 deletions(-)

diff --git a/pttbbs/include/proto.h b/pttbbs/include/proto.h
index 1c72178c..a340a943 100644
--- a/pttbbs/include/proto.h
+++ b/pttbbs/include/proto.h
@@ -1,7 +1,13 @@
-/* $Id: proto.h,v 1.30 2002/11/06 16:25:14 in2 Exp $ */
+/* $Id: proto.h,v 1.31 2002/12/26 09:46:03 kcwu Exp $ */
 #ifndef INCLUDE_PROTO_H
 #define INCLUDE_PROTO_H
 
+#ifdef __GNUC__
+#define GCC_CHECK_FORMAT(a,b) __attribute__ ((format (printf, a, b)))
+#else
+#define GCC_CHECK_FORMAT(a,b)
+#endif
+
 /* admin */
 int m_mod_board(char *bname);
 int m_newbrd(int recover);
@@ -23,7 +29,7 @@ void gem(char* maintitle, item_t* path, int update);
 
 /* args */
 void initsetproctitle(int argc, char **argv, char **envp);
-void setproctitle(const char* format, ...);
+void setproctitle(const char* format, ...) GCC_CHECK_FORMAT(1,2);
 
 /* bbcall */
 int main_bbcall();
@@ -348,7 +354,7 @@ void UnTagger (int locus);
 int substitute_record(char *fpath, void *rptr, int size, int id);
 int lock_substitute_record(char *fpath, void *rptr, int size, int id, int);
 int get_record(char *fpath, void *rptr, int size, int id);
-void prints(char *fmt, ...);
+void prints(char *fmt, ...) GCC_CHECK_FORMAT(1,2);
 int append_record(char *fpath, fileheader_t *record, int size);
 int stampfile(char *fpath, fileheader_t *fh);
 void stampdir(char *fpath, fileheader_t *fh);
@@ -400,7 +406,7 @@ time_t gettime(int line, time_t dt);
 void setcalfile(char *buf, char *userid);
 void stand_title(char *title);
 void pressanykey();
-int  vmsg (const char *fmt,...);
+int  vmsg (const char *fmt,...) GCC_CHECK_FORMAT(1,2);
 void trim(char *buf);
 void bell();
 void setbpath(char *buf, char *boardname);
diff --git a/pttbbs/mbbsd/edit.c b/pttbbs/mbbsd/edit.c
index 0d77f9a8..1107a6f1 100644
--- a/pttbbs/mbbsd/edit.c
+++ b/pttbbs/mbbsd/edit.c
@@ -1,4 +1,4 @@
-/* $Id: edit.c,v 1.22 2002/11/23 04:15:30 ptt Exp $ */
+/* $Id: edit.c,v 1.23 2002/12/26 09:46:04 kcwu Exp $ */
 #include "bbs.h"
 typedef struct textline_t {
     struct textline_t *prev;
@@ -1575,7 +1575,7 @@ int
 vedit(char *fpath, int saveheader, int *islocal)
 {
     FILE           *fp1;
-    char            last = 0, buf[200];	/* the last key you press */
+    char            last = 0;	/* the last key you press */
     int             ch, foo;
     int             lastindent = -1;
     int             last_margin;
@@ -1649,6 +1649,7 @@ vedit(char *fpath, int saveheader, int *islocal)
 	}
 	/* �s��240��interval�@�� , �����O�b�İ] 
 	if (count >= 240) {
+	    char buf[200];
 	    snprintf(buf, sizeof(buf), "\033[1;33;46m%s\033[37m�b\033[37;45m%s"
 		    "\033[37m�O�H�k�ȿ� , %s\033[m", cuser.userid,
 		    currboard, ctime(&now));
diff --git a/pttbbs/mbbsd/gamble.c b/pttbbs/mbbsd/gamble.c
index 836dbc25..8ade3999 100644
--- a/pttbbs/mbbsd/gamble.c
+++ b/pttbbs/mbbsd/gamble.c
@@ -1,4 +1,4 @@
-/* $Id: gamble.c,v 1.28 2002/07/22 19:02:00 in2 Exp $ */
+/* $Id: gamble.c,v 1.29 2002/12/26 09:46:04 kcwu Exp $ */
 #include "bbs.h"
 
 #ifndef _BBS_UTIL_C_
@@ -113,12 +113,11 @@ show_ticket_data(char *direct, int *price, boardheader_t * bh)
 
     prints("\033[32m���W:\033[m 1.�i�ʶR�H�U���P�������m���C�C�i�n�� \033[32m%d\033[m ���C\n"
 	   "      2.%s\n"
-      "      3.�}���ɥu���@�رm������, ���ʶR�ӱm����, �h�i���ʶR���i�Ƨ���"
-	   "�`����C\n"
-	   "      4.�C�������Ѩt�Ω�� 5% ���|��%s�C\n\n"
+	   "      3.�}���ɥu���@�رm������, ���ʶR�ӱm����, �h�i���ʶR���i�Ƨ����`����C\n"
+	   "      4.�C�������Ѩt�Ω�� 5%% ���|��%s�C\n\n"
 	   "\033[32m%s:\033[m", *price,
-     bh ? "����L�ѪO�D�t�d�|��åB�M�w�}���ɶ����G, ��������, �@��A��C" :
-	   "�t�ΨC�� 2:00 11:00 16:00 21:00 �}���C",
+	   bh ? "����L�ѪO�D�t�d�|��åB�M�w�}���ɶ����G, ��������, �@��A��C" :
+	        "�t�ΨC�� 2:00 11:00 16:00 21:00 �}���C",
 	   bh ? ", �䤤 2% �����}���O�D" : "",
 	   bh ? "�O�D�ۭq�W�h�λ���" : "�e�X���}�����G");
 
diff --git a/pttbbs/mbbsd/guess.c b/pttbbs/mbbsd/guess.c
index 0d655108..bd32450c 100644
--- a/pttbbs/mbbsd/guess.c
+++ b/pttbbs/mbbsd/guess.c
@@ -1,4 +1,4 @@
-/* $Id: guess.c,v 1.6 2002/07/22 19:02:00 in2 Exp $ */
+/* $Id: guess.c,v 1.7 2002/12/26 09:46:04 kcwu Exp $ */
 #include "bbs.h"
 #define LOGPASS BBSHOME "/etc/winguess.log"
 
@@ -246,7 +246,7 @@ guess_main()
     Diff_Random(answer);
     move(2, 0);
     clrtoeol();
-    prints("�z�U�` :%d Ptt$", money);
+    prints("�z�U�` :%lu Ptt$", money);
 
     getdata_str(4, 0, "�z�n�M�q�����ɶ�? <y/n>[y]:",
 		ifcomputer, sizeof(ifcomputer), LCECHO, "y");
@@ -292,7 +292,7 @@ guess_main()
 	if (count > c_count) {
 	    prints("�A�鵹�q���F");
 	    move(18, 35);
-	    prints("�A�ߤF %d ", money);
+	    prints("�A�ߤF %lu ", money);
 	    if ((file = fopen(LOGPASS, "a"))) {
 		fprintf(file, "�q����%d���q��, ", c_count);
 		if (youwin)
@@ -308,7 +308,7 @@ guess_main()
 	} else if (count < c_count) {
 	    prints("�u�F�`, ���A�Ȩ��o");
 	    move(18, 35);
-	    prints("�A�Ȩ��F %d ", money * 2);
+	    prints("�A�Ȩ��F %lu ", money * 2);
 	    demoney(money * 2);
 	    if ((file = fopen(LOGPASS, "a"))) {
 		fprintf(file, "id: %s, ��%d���q��, �q����%d���q��, "
@@ -320,7 +320,7 @@ guess_main()
 	    pressanykey();
 	    return 1;
 	} else {
-	    prints("�u�F�`, �M�q����������F, ���^����%d\n", money);
+	    prints("�u�F�`, �M�q����������F, ���^����%lu\n", money);
 	    demoney(money);
 	    if ((file = fopen(LOGPASS, "a"))) {
 		fprintf(file, "id: %s �M�q�������F����\n", cuser.userid);
@@ -351,9 +351,9 @@ guess_main()
 	    prints("�����q�X��, �٧A�����a");
 	    move(18, 35);
 	    clrtoeol();
-	    prints("�A���^�F%d Ptt$\n", money);
+	    prints("�A���^�F%lu Ptt$\n", money);
 	    if ((file = fopen(LOGPASS, "a"))) {
-		fprintf(file, "id: %s, ��%d���q��, ���^�F���� %ld Ptt$\n",
+		fprintf(file, "id: %s, ��%d���q��, ���^�F���� %lu Ptt$\n",
 			cuser.userid, count, money);
 		fclose(file);
 	    }
diff --git a/pttbbs/mbbsd/user.c b/pttbbs/mbbsd/user.c
index d3501822..5de29e36 100644
--- a/pttbbs/mbbsd/user.c
+++ b/pttbbs/mbbsd/user.c
@@ -1,4 +1,4 @@
-/* $Id: user.c,v 1.42 2002/12/14 08:02:18 in2 Exp $ */
+/* $Id: user.c,v 1.43 2002/12/26 09:46:04 kcwu Exp $ */
 #include "bbs.h"
 
 static char    *sex[8] = {
@@ -55,7 +55,7 @@ user_display(userec_t * u, int real)
 	   "                �~�����}: %s\n"
 	   "                �q�l�H�c: %s\n"
 	   "                ��    �O: %s\n"
-	   "                �Ȧ�b��: %ld �Ȩ�\n",
+	   "                �Ȧ�b��: %d �Ȩ�\n",
 	   u->userid, u->username, u->realname, u->address, u->email,
 	   sex[u->sex % 8], u->money);
 
-- 
cgit v1.2.3