From noreply在list.moon.ossxp.com Sat Aug 22 19:01:15 2009 From: noreply在list.moon.ossxp.com (jiangxin) Date: Sat, 22 Aug 2009 19:01:15 +0800 Subject: [Hello-hacks] r1 - / Message-ID: Author: jiangxin Date: 2009-08-22 19:01:15 +0800 (六, 2009-08-22) New Revision: 1 Added: branches/ tags/ trunk/ Log: Initialized From noreply在list.moon.ossxp.com Sat Aug 22 19:02:47 2009 From: noreply在list.moon.ossxp.com (jiangxin) Date: Sat, 22 Aug 2009 19:02:47 +0800 Subject: [Hello-hacks] r2 - in trunk: . src Message-ID: Author: jiangxin Date: 2009-08-22 19:02:46 +0800 (六, 2009-08-22) New Revision: 2 Added: trunk/README trunk/src/ trunk/src/Makefile trunk/src/main.bak trunk/src/main.c Log: Fixed #1: Initialized from hello-1.0.0.tar.gz 已增加: trunk/README =================================================================== --- trunk/README (rev 0) +++ trunk/README 2009-08-22 11:02:46 UTC (rev 2) @@ -0,0 +1,15 @@ += Hello World 项目 (svn) = +Hello World 项目是一个用 C 语言开发的演示项目,主要用于版本控制系统的演示。有 svn 和 hg 两种不同的版本, +分别用 Subversion 和 Mercurial 做版本控制,以演示两种版本库维护第三方版本库的高下。 + +本项目作为 svn 版本库维护的上游版本,对应的下游版本项目页,参见: [[//trac/hello-svn-hacks]] + +相关的概念 + * '''上游版本库''': + 无权在该版本库中 Checkin,如果需要对其中的代码进行定制,只能通过 fork ── 本地重建版本库的方式。 + * '''下游版本库''': + 自己或自己所在的团队,为了修改上游版本库而另外建立的版本库。该版本库用于镜像上游代码,以及维护代码定制。 + * '''卖主分支''': + 使用 Subversion 作为下游版本库维护代码,采用的方法称为卖主分支。即使用一个分支专门用于镜像上游版本库的代码,在主线维护包含定制的代码。 + * '''Hg + MQ''': + 使用 Mercurial(Hg) 以及 Hg 内置的 MQ 插件来维护下游版本库,是一种更为有效的方法。尤其是对上游的定制相当的多和复杂的情况,可以大大减少由于上游版本频繁升级带来的维护负担。这种方法实际上维护的是一系列补丁文件,这些补丁文件使用的是 [[http://savannah.nongnu.org/projects/quilt|quilt]] 格式。 Property changes on: trunk/README ___________________________________________________________________ 已增加: svn:eol-style + native 已增加: trunk/src/Makefile =================================================================== --- trunk/src/Makefile (rev 0) +++ trunk/src/Makefile 2009-08-22 11:02:46 UTC (rev 2) @@ -0,0 +1,14 @@ +OBJECTS = main.o +TARGET = hello + +all: $(TARGET) + +$(TARGET): $(OBJECTS) + $(CC) -o $@ $^ + +clean: + rm -f $(TARGET) $(OBJECTS) + +.PHONY: all clean + +# vim: noet Property changes on: trunk/src/Makefile ___________________________________________________________________ 已增加: svn:eol-style + native 已增加: trunk/src/main.bak =================================================================== Binary files trunk/src/main.bak_(rev_1) and trunk/src/main.bak_(rev_2) differ (二进制文件不同) Property changes on: trunk/src/main.bak ___________________________________________________________________ 已增加: svn:mime-type + application/x-trash 已增加: trunk/src/main.c =================================================================== --- trunk/src/main.c (rev 0) +++ trunk/src/main.c 2009-08-22 11:02:46 UTC (rev 2) @@ -0,0 +1,29 @@ +#include + +int usage(int code) +{ + printf("Hello world example.\n" + "Copyright Jiang Xin , 2009\n" + "\n" + "Usage:\n" + " hello\n" + " say hello to the world.\n\n" + " hello \n" + " say hi to the user.\n\n" + " hello -h, -help\n" + " this help screen.\n\n"); + return code; +} + +int +main(int argc, char **argv) +{ + if (argc == 1) { + printf ("Hello world.\n"); + } else if ( strcmp(argv[1],"-h") == 0 || + strcmp(argv[1],"--help") == 0 ) { + return usage(0); + } else { + printf ("Hi, %s.\n", argv[1]); + } +} Property changes on: trunk/src/main.c ___________________________________________________________________ 已增加: svn:mime-type + text/plain 已增加: svn:eol-style + native From noreply在list.moon.ossxp.com Sat Aug 22 19:23:36 2009 From: noreply在list.moon.ossxp.com (user1) Date: Sat, 22 Aug 2009 19:23:36 +0800 Subject: [Hello-hacks] r3 - trunk/src Message-ID: Author: user1 Date: 2009-08-22 19:23:36 +0800 (六, 2009-08-22) New Revision: 3 Modified: trunk/src/main.c Log: Fixed #2: -help changed to --help. 已修改: trunk/src/main.c =================================================================== --- trunk/src/main.c 2009-08-22 11:02:46 UTC (rev 2) +++ trunk/src/main.c 2009-08-22 11:23:36 UTC (rev 3) @@ -10,7 +10,7 @@ " say hello to the world.\n\n" " hello \n" " say hi to the user.\n\n" - " hello -h, -help\n" + " hello -h, --help\n" " this help screen.\n\n"); return code; } From noreply在list.moon.ossxp.com Sat Aug 22 19:27:13 2009 From: noreply在list.moon.ossxp.com (jiangxin) Date: Sat, 22 Aug 2009 19:27:13 +0800 Subject: [Hello-hacks] r4 - trunk/src Message-ID: Author: jiangxin Date: 2009-08-22 19:27:13 +0800 (六, 2009-08-22) New Revision: 4 Modified: trunk/src/main.c Log: Fixed #3: concat all trailing args as username 已修改: trunk/src/main.c =================================================================== --- trunk/src/main.c 2009-08-22 11:23:36 UTC (rev 3) +++ trunk/src/main.c 2009-08-22 11:27:13 UTC (rev 4) @@ -24,6 +24,11 @@ strcmp(argv[1],"--help") == 0 ) { return usage(0); } else { - printf ("Hi, %s.\n", argv[1]); + char **p = &argv[1]; + printf ("Hi,"); + do { + printf (" %s", *p); + } while (*(++p)); + printf (".\n"); } } From noreply在list.moon.ossxp.com Sat Aug 22 19:33:52 2009 From: noreply在list.moon.ossxp.com (jiangxin) Date: Sat, 22 Aug 2009 19:33:52 +0800 Subject: [Hello-hacks] r5 - in trunk/src: . locale locale/zh_CN locale/zh_CN/LC_MESSAGES Message-ID: Author: jiangxin Date: 2009-08-22 19:33:52 +0800 (六, 2009-08-22) New Revision: 5 Added: trunk/src/locale/ trunk/src/locale/helloworld.pot trunk/src/locale/zh_CN/ trunk/src/locale/zh_CN/LC_MESSAGES/ trunk/src/locale/zh_CN/LC_MESSAGES/helloworld.po Modified: trunk/src/Makefile trunk/src/main.c Log: See #4: add i18n to helloworld using gnu gettext. 已修改: trunk/src/Makefile =================================================================== --- trunk/src/Makefile 2009-08-22 11:27:13 UTC (rev 4) +++ trunk/src/Makefile 2009-08-22 11:33:52 UTC (rev 5) @@ -3,9 +3,26 @@ all: $(TARGET) -$(TARGET): $(OBJECTS) - $(CC) -o $@ $^ +$(TARGET): $(OBJECTS) mo + $(CC) -o $@ $(OBJECTS) +POT=locale/helloworld.pot +pot: $(POT) +$(POT): main.c + @mkdir -p locale/zh_CN/LC_MESSAGES + xgettext -s -k_ -o $@ $^ + +po: pot locale/zh_CN/LC_MESSAGES/helloworld.po +locale/zh_CN/LC_MESSAGES/helloworld.po: $(POT) + if [ ! -f $@ ]; then msginit -i $(POT) -o $@; fi + msgmerge $@ $< -o locale/temp.po + mv locale/temp.po $@ + +mo:: po +mo:: locale/zh_CN/LC_MESSAGES/helloworld.mo +locale/zh_CN/LC_MESSAGES/helloworld.mo: locale/zh_CN/LC_MESSAGES/helloworld.po + msgfmt -o $@ $< + clean: rm -f $(TARGET) $(OBJECTS) 已增加: trunk/src/locale/helloworld.pot =================================================================== --- trunk/src/locale/helloworld.pot (rev 0) +++ trunk/src/locale/helloworld.pot 2009-08-22 11:33:52 UTC (rev 5) @@ -0,0 +1,45 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2009-08-22 19:32+0800\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: main.c:11 +#, c-format +msgid "" +"Hello world example.\n" +"Copyright Jiang Xin , 2009\n" +"\n" +"Usage:\n" +" hello\n" +" say hello to the world.\n" +"\n" +" hello \n" +" say hi to the user.\n" +"\n" +" hello -h, --help\n" +" this help screen.\n" +"\n" +msgstr "" + +#: main.c:32 +#, c-format +msgid "Hello world.\n" +msgstr "" + +#: main.c:38 +#, c-format +msgid "Hi," +msgstr "" Property changes on: trunk/src/locale/helloworld.pot ___________________________________________________________________ 已增加: svn:mime-type + text/plain 已增加: svn:eol-style + native 已增加: trunk/src/locale/zh_CN/LC_MESSAGES/helloworld.po =================================================================== --- trunk/src/locale/zh_CN/LC_MESSAGES/helloworld.po (rev 0) +++ trunk/src/locale/zh_CN/LC_MESSAGES/helloworld.po 2009-08-22 11:33:52 UTC (rev 5) @@ -0,0 +1,45 @@ +# Chinese translations for PACKAGE package +# PACKAGE 软件包的简体中文翻译. +# Copyright (C) 2009 THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# JiangXin , 2009. +# +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2009-08-22 19:32+0800\n" +"PO-Revision-Date: 2009-08-22 14:58+0800\n" +"Last-Translator: JiangXin \n" +"Language-Team: Chinese (simplified)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: main.c:11 +#, c-format +msgid "" +"Hello world example.\n" +"Copyright Jiang Xin , 2009\n" +"\n" +"Usage:\n" +" hello\n" +" say hello to the world.\n" +"\n" +" hello \n" +" say hi to the user.\n" +"\n" +" hello -h, --help\n" +" this help screen.\n" +"\n" +msgstr "" + +#: main.c:32 +#, c-format +msgid "Hello world.\n" +msgstr "" + +#: main.c:38 +#, c-format +msgid "Hi," +msgstr "" Property changes on: trunk/src/locale/zh_CN/LC_MESSAGES/helloworld.po ___________________________________________________________________ 已增加: svn:eol-style + native 已修改: trunk/src/main.c =================================================================== --- trunk/src/main.c 2009-08-22 11:27:13 UTC (rev 4) +++ trunk/src/main.c 2009-08-22 11:33:52 UTC (rev 5) @@ -1,8 +1,14 @@ #include +#include +#include +#define _(String) gettext (String) +#define gettext_noop(String) String +#define N_(String) gettext_noop (String) + int usage(int code) { - printf("Hello world example.\n" + printf( _("Hello world example.\n" "Copyright Jiang Xin , 2009\n" "\n" "Usage:\n" @@ -11,21 +17,25 @@ " hello \n" " say hi to the user.\n\n" " hello -h, --help\n" - " this help screen.\n\n"); + " this help screen.\n\n") ); return code; } int main(int argc, char **argv) { + setlocale( LC_ALL, "" ); + bindtextdomain("helloworld","locale"); + textdomain("helloworld"); + if (argc == 1) { - printf ("Hello world.\n"); + printf ( _("Hello world.\n") ); } else if ( strcmp(argv[1],"-h") == 0 || strcmp(argv[1],"--help") == 0 ) { return usage(0); } else { char **p = &argv[1]; - printf ("Hi,"); + printf ( _("Hi,") ); do { printf (" %s", *p); } while (*(++p)); From noreply在list.moon.ossxp.com Sat Aug 22 19:38:17 2009 From: noreply在list.moon.ossxp.com (wangqiaojie) Date: Sat, 22 Aug 2009 19:38:17 +0800 Subject: [Hello-hacks] r6 - trunk/src/locale/zh_CN/LC_MESSAGES Message-ID: Author: wangqiaojie Date: 2009-08-22 19:38:17 +0800 (六, 2009-08-22) New Revision: 6 Modified: trunk/src/locale/zh_CN/LC_MESSAGES/helloworld.po Log: Fixed #4: translate locale file for zh_CN. 已修改: trunk/src/locale/zh_CN/LC_MESSAGES/helloworld.po =================================================================== --- trunk/src/locale/zh_CN/LC_MESSAGES/helloworld.po 2009-08-22 11:33:52 UTC (rev 5) +++ trunk/src/locale/zh_CN/LC_MESSAGES/helloworld.po 2009-08-22 11:38:17 UTC (rev 6) @@ -1,3 +1,4 @@ +# translation of helloworld.po to # Chinese translations for PACKAGE package # PACKAGE 软件包的简体中文翻译. # Copyright (C) 2009 THE PACKAGE'S COPYRIGHT HOLDER @@ -2,15 +3,17 @@ # This file is distributed under the same license as the PACKAGE package. +# # JiangXin , 2009. -# +# Jiang Xin , 2009. msgid "" msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" +"Project-Id-Version: helloworld\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2009-08-22 19:32+0800\n" -"PO-Revision-Date: 2009-08-22 14:58+0800\n" -"Last-Translator: JiangXin \n" -"Language-Team: Chinese (simplified)\n" +"PO-Revision-Date: 2009-08-22 19:36+0800\n" +"Last-Translator: Jiang Xin \n" +"Language-Team: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" +"X-Generator: KBabel 1.11.4\n" @@ -33,13 +36,27 @@ " this help screen.\n" "\n" msgstr "" +"Hello world 示例。\n" +"版权所有 Jiang Xin , 2009\n" +"\n" +"用法:\n" +" hello\n" +" 世界你好。\n" +"\n" +" hello \n" +" 向用户问您好。\n" +"\n" +" hello -h, --help\n" +" 本帮助页。\n" +"\n" #: main.c:32 #, c-format msgid "Hello world.\n" -msgstr "" +msgstr "世界你好。\n" #: main.c:38 #, c-format msgid "Hi," -msgstr "" +msgstr "您好," + From noreply在list.moon.ossxp.com Sat Aug 22 19:41:24 2009 From: noreply在list.moon.ossxp.com (jiangxin) Date: Sat, 22 Aug 2009 19:41:24 +0800 Subject: [Hello-hacks] r7 - tags Message-ID: Author: jiangxin Date: 2009-08-22 19:41:23 +0800 (六, 2009-08-22) New Revision: 7 Added: tags/hacks-1.0.0/ Log: 里程碑 hacks-1.0.0 From noreply在list.moon.ossxp.com Sat Aug 22 19:41:39 2009 From: noreply在list.moon.ossxp.com (jiangxin) Date: Sat, 22 Aug 2009 19:41:39 +0800 Subject: [Hello-hacks] r8 - branches Message-ID: Author: jiangxin Date: 2009-08-22 19:41:39 +0800 (六, 2009-08-22) New Revision: 8 Added: branches/hacks-1.x/ Log: 分支 hacks-1.x From noreply在list.moon.ossxp.com Sat Aug 22 19:52:04 2009 From: noreply在list.moon.ossxp.com (jiangxin) Date: Sat, 22 Aug 2009 19:52:04 +0800 Subject: [Hello-hacks] r9 - tags Message-ID: Author: jiangxin Date: 2009-08-22 19:52:04 +0800 (六, 2009-08-22) New Revision: 9 Added: tags/hello-1.0.0/ Log: 参见 #6: 从历史版本建立里程碑 hello-1.0.0 From noreply在list.moon.ossxp.com Sat Aug 22 19:52:47 2009 From: noreply在list.moon.ossxp.com (jiangxin) Date: Sat, 22 Aug 2009 19:52:47 +0800 Subject: [Hello-hacks] r10 - branches Message-ID: Author: jiangxin Date: 2009-08-22 19:52:46 +0800 (六, 2009-08-22) New Revision: 10 Added: branches/hello-upstream/ Log: 修复 #6: 从历史版本创建卖主分支 hello-upstream From noreply在list.moon.ossxp.com Sat Aug 22 19:55:55 2009 From: noreply在list.moon.ossxp.com (jiangxin) Date: Sat, 22 Aug 2009 19:55:55 +0800 Subject: [Hello-hacks] r11 - branches/hello-upstream/src Message-ID: Author: jiangxin Date: 2009-08-22 19:55:54 +0800 (六, 2009-08-22) New Revision: 11 Added: branches/hello-upstream/src/COPYRIGHT Removed: branches/hello-upstream/src/main.bak Modified: branches/hello-upstream/src/main.c Log: Fixed #6:从 hello-2.0.0.tar.gz 导入代码 已增加: branches/hello-upstream/src/COPYRIGHT =================================================================== --- branches/hello-upstream/src/COPYRIGHT (rev 0) +++ branches/hello-upstream/src/COPYRIGHT 2009-08-22 11:55:54 UTC (rev 11) @@ -0,0 +1 @@ +Copyright Jiang Xin , 2009. Property changes on: branches/hello-upstream/src/COPYRIGHT ___________________________________________________________________ 已增加: svn:eol-style + native 已删除: branches/hello-upstream/src/main.bak =================================================================== Binary files branches/hello-upstream/src/main.bak_(rev_10) and branches/hello-upstream/src/main.bak_(rev_11) differ (二进制文件不同) 已修改: branches/hello-upstream/src/main.c =================================================================== --- branches/hello-upstream/src/main.c 2009-08-22 11:52:46 UTC (rev 10) +++ branches/hello-upstream/src/main.c 2009-08-22 11:55:54 UTC (rev 11) @@ -1,4 +1,5 @@ #include +#include int usage(int code) { @@ -18,12 +19,41 @@ int main(int argc, char **argv) { - if (argc == 1) { + int c; + char *uname = NULL; + + while (1) { + int option_index = 0; + static struct option long_options[] = { + {"help", 0, 0, 'h'}, + {0, 0, 0, 0} + }; + + c = getopt_long(argc, argv, "h", + long_options, &option_index); + if (c == -1) + break; + + switch (c) { + case 'h': + return usage(0); + default: + return usage(1); + } + } + + if (optind < argc) { + uname = argv[optind]; + } + + if (uname == NULL) { printf ("Hello world.\n"); - } else if ( strcmp(argv[1],"-h") == 0 || - strcmp(argv[1],"--help") == 0 ) { - return usage(0); } else { - printf ("Hi, %s.\n", argv[1]); + printf ("Hi, %s.\n", uname); } } + + +/* + * vim: et ts=4 sw=4 + */ From noreply在list.moon.ossxp.com Sat Aug 22 19:57:07 2009 From: noreply在list.moon.ossxp.com (jiangxin) Date: Sat, 22 Aug 2009 19:57:07 +0800 Subject: [Hello-hacks] r12 - tags Message-ID: Author: jiangxin Date: 2009-08-22 19:57:06 +0800 (六, 2009-08-22) New Revision: 12 Added: tags/hello-2.0.0/ Log: 参见 #6: 创建里程碑 hello-2.0.0 From noreply在list.moon.ossxp.com Sat Aug 22 20:01:45 2009 From: noreply在list.moon.ossxp.com (jiangxin) Date: Sat, 22 Aug 2009 20:01:45 +0800 Subject: [Hello-hacks] r13 - in trunk/src: . locale locale/zh_CN/LC_MESSAGES Message-ID: Author: jiangxin Date: 2009-08-22 20:01:44 +0800 (六, 2009-08-22) New Revision: 13 Added: trunk/src/COPYRIGHT Removed: trunk/src/main.bak Modified: trunk/src/locale/helloworld.pot trunk/src/locale/zh_CN/LC_MESSAGES/helloworld.po trunk/src/main.c Log: Fixed #7: 合并上游 hello-2.0.0 版本 已复制: trunk/src/COPYRIGHT (来自版本 12,branches/hello-upstream/src/COPYRIGHT) =================================================================== --- trunk/src/COPYRIGHT (rev 0) +++ trunk/src/COPYRIGHT 2009-08-22 12:01:44 UTC (rev 13) @@ -0,0 +1 @@ +Copyright Jiang Xin , 2009. 已修改: trunk/src/locale/helloworld.pot =================================================================== --- trunk/src/locale/helloworld.pot 2009-08-22 11:57:06 UTC (rev 12) +++ trunk/src/locale/helloworld.pot 2009-08-22 12:01:44 UTC (rev 13) @@ -8,7 +8,7 @@ msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2009-08-22 19:32+0800\n" +"POT-Creation-Date: 2009-08-22 20:00+0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -16,7 +16,7 @@ "Content-Type: text/plain; charset=CHARSET\n" "Content-Transfer-Encoding: 8bit\n" -#: main.c:11 +#: main.c:12 #, c-format msgid "" "Hello world example.\n" @@ -34,12 +34,12 @@ "\n" msgstr "" -#: main.c:32 +#: main.c:58 #, c-format msgid "Hello world.\n" msgstr "" -#: main.c:38 +#: main.c:60 #, c-format msgid "Hi," msgstr "" 已修改: trunk/src/locale/zh_CN/LC_MESSAGES/helloworld.po =================================================================== --- trunk/src/locale/zh_CN/LC_MESSAGES/helloworld.po 2009-08-22 11:57:06 UTC (rev 12) +++ trunk/src/locale/zh_CN/LC_MESSAGES/helloworld.po 2009-08-22 12:01:44 UTC (rev 13) @@ -10,7 +10,7 @@ msgstr "" "Project-Id-Version: helloworld\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2009-08-22 19:32+0800\n" +"POT-Creation-Date: 2009-08-22 20:00+0800\n" "PO-Revision-Date: 2009-08-22 19:36+0800\n" "Last-Translator: Jiang Xin \n" "Language-Team: \n" @@ -19,7 +19,7 @@ "Content-Transfer-Encoding: 8bit\n" "X-Generator: KBabel 1.11.4\n" -#: main.c:11 +#: main.c:12 #, c-format msgid "" "Hello world example.\n" @@ -50,13 +50,12 @@ " 本帮助页。\n" "\n" -#: main.c:32 +#: main.c:58 #, c-format msgid "Hello world.\n" msgstr "世界你好。\n" -#: main.c:38 +#: main.c:60 #, c-format msgid "Hi," msgstr "您好," - 已删除: trunk/src/main.bak =================================================================== Binary files trunk/src/main.bak_(rev_12) and trunk/src/main.bak_(rev_13) differ (二进制文件不同) 已修改: trunk/src/main.c =================================================================== --- trunk/src/main.c 2009-08-22 11:57:06 UTC (rev 12) +++ trunk/src/main.c 2009-08-22 12:01:44 UTC (rev 13) @@ -1,4 +1,5 @@ #include +#include #include #include @@ -28,13 +29,34 @@ bindtextdomain("helloworld","locale"); textdomain("helloworld"); - if (argc == 1) { + int c; + char **p = NULL; + + while (1) { + int option_index = 0; + static struct option long_options[] = { + {"help", 0, 0, 'h'}, + {0, 0, 0, 0} + }; + + c = getopt_long(argc, argv, "h", + long_options, &option_index); + if (c == -1) + break; + + switch (c) { + case 'h': + return usage(0); + default: + return usage(1); + } + } + + p = &argv[optind]; + + if (*p == NULL) { printf ( _("Hello world.\n") ); - } else if ( strcmp(argv[1],"-h") == 0 || - strcmp(argv[1],"--help") == 0 ) { - return usage(0); } else { - char **p = &argv[1]; printf ( _("Hi,") ); do { printf (" %s", *p); @@ -42,3 +64,8 @@ printf (".\n"); } } + + +/* + * vim: et ts=4 sw=4 + */ From noreply在list.moon.ossxp.com Sat Aug 22 20:04:49 2009 From: noreply在list.moon.ossxp.com (jiangxin) Date: Sat, 22 Aug 2009 20:04:49 +0800 Subject: [Hello-hacks] r14 - tags tags/hacks-2.0.0 trunk Message-ID: Author: jiangxin Date: 2009-08-22 20:04:49 +0800 (六, 2009-08-22) New Revision: 14 Added: tags/hacks-2.0.0/ Modified: trunk/ Log: Fixed #8: 创建里程碑 hacks-2.0.0 Property changes on: tags/hacks-2.0.0 ___________________________________________________________________ 已增加: svn:mergeinfo + /branches/hello-upstream:3-12 Property changes on: trunk ___________________________________________________________________ 已增加: svn:mergeinfo + /branches/hello-upstream:3-12