ICU-1852 sample cleanup - wave #1
X-SVN-Rev: 8470
diff --git a/.gitignore b/.gitignore
index 4817bb4..b797a56 100644
--- a/.gitignore
+++ b/.gitignore
@@ -138,13 +138,13 @@
icu4c/source/samples/cal/Debug
icu4c/source/samples/cal/Makefile
icu4c/source/samples/cal/Release
-icu4c/source/samples/cal/cal
+icu4c/source/samples/cal/icucal
icu4c/source/samples/date/*.d
icu4c/source/samples/date/*.pdb
icu4c/source/samples/date/Debug
icu4c/source/samples/date/Makefile
icu4c/source/samples/date/Release
-icu4c/source/samples/date/date
+icu4c/source/samples/date/icudate
icu4c/source/samples/layout/Makefile
icu4c/source/stubdata/*.ao
icu4c/source/stubdata/*.d
diff --git a/icu4c/source/samples/cal/.cvsignore b/icu4c/source/samples/cal/.cvsignore
index ce213cf..bb2892f 100644
--- a/icu4c/source/samples/cal/.cvsignore
+++ b/icu4c/source/samples/cal/.cvsignore
@@ -3,4 +3,4 @@
Makefile
*.d
*.pdb
-cal
+icucal
diff --git a/icu4c/source/samples/cal/Makefile.in b/icu4c/source/samples/cal/Makefile.in
index f86238f..91d95a3 100644
--- a/icu4c/source/samples/cal/Makefile.in
+++ b/icu4c/source/samples/cal/Makefile.in
@@ -20,7 +20,7 @@
CLEANFILES = *~ $(DEPS)
## Target information
-TARGET = cal
+TARGET = icucal
ENABLE_STATIC = @ENABLE_STATIC@
@@ -74,6 +74,7 @@
$(RMV) Makefile
check-local:
+ -$(INVOKE) $(TARGET)
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
cd $(top_builddir) \
diff --git a/icu4c/source/samples/cal/cal.c b/icu4c/source/samples/cal/cal.c
index 691449f..77e93ed 100644
--- a/icu4c/source/samples/cal/cal.c
+++ b/icu4c/source/samples/cal/cal.c
@@ -124,7 +124,7 @@
/* Make sure the month value is legal */
if(month < 0 || month > 12) {
- printf("cal: Bad value for month -- %d\n", month);
+ printf("icucal: Bad value for month -- %d\n", month);
/* Display usage */
printUsage = 1;
@@ -164,7 +164,7 @@
static void
usage()
{
- puts("Usage: cal [OPTIONS] [[MONTH] YEAR]");
+ puts("Usage: icucal [OPTIONS] [[MONTH] YEAR]");
puts("");
puts("Options:");
puts(" -h, --help Print this message and exit.");
@@ -182,10 +182,9 @@
static void
version()
{
- printf("cal version %s (ICU version %s), created by Stephen F. Booth.\n",
+ printf("icucal version %s (ICU version %s), created by Stephen F. Booth.\n",
CAL_VERSION, U_ICU_VERSION);
- puts("Copyright (C) 1998-2000 International Business Machines Corporation and others.");
- puts("All Rights Reserved.");
+ puts(U_COPYRIGHT_STRING);
}
static void
diff --git a/icu4c/source/samples/cal/readme.txt b/icu4c/source/samples/cal/readme.txt
new file mode 100644
index 0000000..7b16eaa
--- /dev/null
+++ b/icu4c/source/samples/cal/readme.txt
@@ -0,0 +1,57 @@
+icucal: a sample program which displays the calendar.
+
+This sample demonstrates
+ Formatting a calendar
+ Outputting text in the default codepage to the console
+
+
+Files:
+ cal.c Main source file
+ uprint.h codepage output convenience header
+ uprint.h codepage output convenience implementation
+ cal.dsw Windows MSVC workspace. Double-click this to get started.
+ cal.dsp Windows MSVC project file
+
+To Build icucal on Windows
+ 1. Install and build ICU
+ 2. In MSVC, open the workspace file icu\samples\cal\cal.dsw
+ 3. Choose a Debug or Release build.
+ 4. Build.
+
+To Run on Windows
+ 1. Start a command shell window
+ 2. Add ICU's bin directory to the path, e.g.
+ set PATH=c:\icu\bin;%PATH%
+ (Use the path to where ever ICU is on your system.)
+ 3. cd into the cal directory, e.g.
+ cd c:\icu\source\samples\cal\debug
+ 4. Run it
+ cal
+
+To Build on Unixes
+ 1. Build ICU. icucal is built automatically by default unless samples are turned off.
+ Specify an ICU install directory when running configure,
+ using the --prefix option. The steps to build ICU will look something
+ like this:
+ cd <icu directory>/source
+ runConfigureICU <platform-name> --prefix <icu install directory> [other options]
+ gmake all
+
+ 2. Install ICU,
+ gmake install
+
+ To Run on Unixes
+ cd <icu directory>/source/samples/cal
+
+ gmake check
+ -or-
+
+ export LD_LIBRARY_PATH=<icu install directory>/lib:.:$LD_LIBRARY_PATH
+ cal
+
+
+ Note: The name of the LD_LIBRARY_PATH variable is different on some systems.
+ If in doubt, run the sample using "gmake check", and note the name of
+ the variable that is used there. LD_LIBRARY_PATH is the correct name
+ for Linux and Solaris.
+
diff --git a/icu4c/source/samples/date/.cvsignore b/icu4c/source/samples/date/.cvsignore
index a629e22..dd76dcb 100644
--- a/icu4c/source/samples/date/.cvsignore
+++ b/icu4c/source/samples/date/.cvsignore
@@ -3,4 +3,4 @@
Makefile
*.d
*.pdb
-date
+icudate
diff --git a/icu4c/source/samples/date/Makefile.in b/icu4c/source/samples/date/Makefile.in
index fb02221..39e7e1c 100644
--- a/icu4c/source/samples/date/Makefile.in
+++ b/icu4c/source/samples/date/Makefile.in
@@ -20,7 +20,7 @@
CLEANFILES = *~ $(DEPS)
## Target information
-TARGET = date
+TARGET = icudate
ENABLE_STATIC = @ENABLE_STATIC@
@@ -74,6 +74,7 @@
$(RMV) Makefile
check-local:
+ -$(INVOKE) $(TARGET)
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
cd $(top_builddir) \
diff --git a/icu4c/source/samples/date/date.c b/icu4c/source/samples/date/date.c
index 9a3ce66..8032ad3 100644
--- a/icu4c/source/samples/date/date.c
+++ b/icu4c/source/samples/date/date.c
@@ -95,7 +95,7 @@
}
/* unrecognized option */
else if(strncmp(arg, "-", strlen("-")) == 0) {
- printf("date: invalid option -- %s\n", arg+1);
+ printf("icudate: invalid option -- %s\n", arg+1);
printUsage = 1;
}
/* done with options, display date */
@@ -127,7 +127,7 @@
static void
usage()
{
- puts("Usage: date [OPTIONS]");
+ puts("Usage: icudate [OPTIONS]");
puts("Options:");
puts(" -h, --help Print this message and exit.");
puts(" -v, --version Print the version number of date and exit.");
@@ -142,10 +142,9 @@
static void
version()
{
- printf("date version %s (ICU version %s), created by Stephen F. Booth.\n",
+ printf("icudate version %s (ICU version %s), created by Stephen F. Booth.\n",
DATE_VERSION, U_ICU_VERSION);
- puts("Copyright (C) 1998-2000 International Business Machines Corporation and others.");
- puts("All Rights Reserved.");
+ puts(U_COPYRIGHT_STRING);
}
/* Format the date */
diff --git a/icu4c/source/samples/date/readme.txt b/icu4c/source/samples/date/readme.txt
new file mode 100644
index 0000000..646e22e
--- /dev/null
+++ b/icu4c/source/samples/date/readme.txt
@@ -0,0 +1,57 @@
+icudate: a sample program which displays the current date
+
+This sample demonstrates
+ Formatting a date
+ Outputting text in the default codepage to the console
+
+
+Files:
+ date.c Main source file
+ uprint.h codepage output convenience header
+ uprint.h codepage output convenience implementation
+ date.dsw Windows MSVC workspace. Double-click this to get started.
+ date.dsp Windows MSVC project file
+
+To Build icudate on Windows
+ 1. Install and build ICU
+ 2. In MSVC, open the workspace file icu\samples\date\date.dsw
+ 3. Choose a Debug or Release build.
+ 4. Build.
+
+To Run on Windows
+ 1. Start a command shell window
+ 2. Add ICU's bin directory to the path, e.g.
+ set PATH=c:\icu\bin;%PATH%
+ (Use the path to where ever ICU is on your system.)
+ 3. cd into the icudate directory, e.g.
+ cd c:\icu\source\samples\date\debug
+ 4. Run it
+ date
+
+To Build on Unixes
+ 1. Build ICU. icudate is built automatically by default unless samples are turned off.
+ Specify an ICU install directory when running configure,
+ using the --prefix option. The steps to build ICU will look something
+ like this:
+ cd <icu directory>/source
+ runConfigureICU <platform-name> --prefix <icu install directory> [other options]
+ gmake all
+
+ 2. Install ICU,
+ gmake install
+
+ To Run on Unixes
+ cd <icu directory>/source/samples/date
+
+ gmake check
+ -or-
+
+ export LD_LIBRARY_PATH=<icu install directory>/lib:.:$LD_LIBRARY_PATH
+ date
+
+
+ Note: The name of the LD_LIBRARY_PATH variable is different on some systems.
+ If in doubt, run the sample using "gmake check", and note the name of
+ the variable that is used there. LD_LIBRARY_PATH is the correct name
+ for Linux and Solaris.
+
diff --git a/icu4c/source/samples/datefmt/Makefile b/icu4c/source/samples/datefmt/Makefile
index 7b87327..55cff28 100644
--- a/icu4c/source/samples/datefmt/Makefile
+++ b/icu4c/source/samples/datefmt/Makefile
@@ -50,7 +50,7 @@
# Make check: simply runs the sample, logged to a file
check: $(TARGET)
- $(TARGET) | tee $(TARGET).out
+ $(INVOKE) ./$(TARGET) | tee $(TARGET).out
# Make report: creates a 'report file' with both source and sample run
report: $(TARGET).report
@@ -59,7 +59,7 @@
more $(TARGET).cpp $(TARGET).out > $@
$(ICU_INC):
- @echo "Please read the directions at the top of this file (Makefile)"
+ @echo "Please read the directions at the top of this file (Makefile) and the README"
@echo "Can't open $(ICU_INC)"
@false
diff --git a/icu4c/source/samples/datefmt/README.TXT b/icu4c/source/samples/datefmt/README.TXT
index cf43a87..d01f771 100644
--- a/icu4c/source/samples/datefmt/README.TXT
+++ b/icu4c/source/samples/datefmt/README.TXT
@@ -1,4 +1,6 @@
This is an exercise for the ICU Workshop (September 2000).
+** Workshop homepage is:
+ http://oss.software.ibm.com/icu/docs/workshop_2000/agenda.html
Day 2: September 12th 2000
Pre-requsit:
@@ -21,24 +23,18 @@
INSTRUCTIONS
------------
-This exercise was developed and tested on ICU release 1.6.0, Win32,
+This exercise was first developed and tested on ICU release 1.6.0, Win32,
Microsoft Visual C++ 6.0. It should work on other ICU releases and
other platforms as well.
-To install: Create a folder "datefmt" at:
+ MSVC:
+ Open the file "datefmt.dsw" in Microsoft Visual C++.
- <icu>/source/samples/datefmt
-
-Within it, place the files:
-
- datefmt.dsp
- datefmt.dsw
- main.cpp
- util.cpp
- util.h
-
-Open the file "datefmt.dsw" in Microsoft Visual C++.
-
+ Unix:
+ - Build and install ICU with a prefix, for example '--prefix=/home/srl/ICU'
+ - Set the variable ICU_PREFIX=/home/srl/ICU and use GNU make in
+ this directory.
+ - You may use 'make check' to invoke this sample.
PROBLEMS
--------
diff --git a/icu4c/source/samples/legacy/Makefile b/icu4c/source/samples/legacy/Makefile
index 69f91d7..97ebbbe 100644
--- a/icu4c/source/samples/legacy/Makefile
+++ b/icu4c/source/samples/legacy/Makefile
@@ -1,5 +1,5 @@
# Copyright (c) 2001 IBM, Inc. and others
-# conversion sample code $Revision: 1.1 $
+# conversion sample code $Revision: 1.2 $
# Usage:
@@ -8,26 +8,23 @@
#
# - do 'make install' of icu
#
-# - change the following line to point to the $(prefix) that
-# was used (will look for $(prefix)/lib/icu/Makefile.inc )
-# OR
-# set the variable ICU_PREFIX to point at $(prefix)
+# - set the variable ICU_PREFIX to point at $(prefix)
+# (will look for $(prefix)/lib/icu/Makefile.inc )
+#
+# - set the variable ICU_LEGACY (read the README)
+# ( Will look for ICU_LEGACY/include/unicode/ucol.h )
#
# - do 'make' in this directory
-ICU_PREFIX=/home/weiv/build/current
-ICU_LEGACY = /home/weiv/build/icu-1-8-1
+#ICU_PREFIX=/home/weiv/build/current
+#ICU_LEGACY = /home/weiv/build/icu-1-8-1
+
LEGACY_INCLUDE = $(ICU_LEGACY)/include
-
-ifeq ($(strip $(ICU_PREFIX)),)
- ICU_INC=$(ICU_DEFAULT_PREFIX)/lib/icu/Makefile.inc
-else
- ICU_INC=$(ICU_PREFIX)/lib/icu/Makefile.inc
-endif
+ICU_INC=$(ICU_PREFIX)/lib/icu/Makefile.inc
ICUPATH=
-include $(ICU_INC)
+-include $(ICU_INC)
# Name of your target
TARGET=legacy
@@ -42,12 +39,11 @@
# turn on super warnings
#CPPFLAGS += -Wall
-
-all: $(TARGET)
+all: $(TARGET) $(ICU_INC)
.PHONY: all clean distclean check report
-oldcol.o : oldcol.cpp
+oldcol.o : oldcol.cpp $(LEGACY_INCLUDE)/unicode/ucol.h
$(CXX) -I$(LEGACY_INCLUDE) $(DEFS) $(CPPFLAGS) $(CXXFLAGS) -c oldcol.cpp
distclean clean:
@@ -62,7 +58,7 @@
# Make check: simply runs the sample, logged to a file
check: $(TARGET)
- $(TARGET) | tee $(TARGET).out
+ $(INVOKE) ./$(TARGET) | tee $(TARGET).out
# Make report: creates a 'report file' with both source and sample run
report: $(TARGET).report
@@ -71,10 +67,19 @@
more $(TARGET).cpp $(TARGET).out > $@
$(ICU_INC):
+ @echo ICU_PREFIX variable is not set correctly
@echo "Please read the directions at the top of this file (Makefile)"
+ @echo "And the README"
@echo "Can't open $(ICU_INC)"
@false
+$(LEGACY_INCLUDE)/unicode/ucol.h:
+ @echo ICU_LEGACY variable is not set correctly.
+ @echo "Please read the directions at the top of this file (Makefile)"
+ @echo "And the README"
+ @echo "Can't open $@"
+ @false
+
ifneq ($(MAKECMDGOALS),distclean)
-include $(DEPS)
endif
diff --git a/icu4c/source/samples/legacy/README b/icu4c/source/samples/legacy/README
index da9fa68..d0e798b 100644
--- a/icu4c/source/samples/legacy/README
+++ b/icu4c/source/samples/legacy/README
@@ -14,7 +14,10 @@
Building and running of the example:
Linux:
-To make it work, you should build and install both the current ICU and ICU 1.8.1. Put both data libraries to wherever ICU_DATA points (usually it is $(prefix)/share/icu/$(icu_version)/). Copy libicuuc.so.18* and libicui18n.so.18* to $(prefix)/lib directory, together with current libraries).
+To make it work, you should build and install both the current ICU and ICU 1.8.1. Put both data libraries to wherever ICU_DATA points (usually it is $(prefix)/share/icu/$(icu_version)/). If data libraries are used, then check for $(prefix)/lib/icu/1.8.1 which should contain libicudata.so and libicudt18*.so
+2. Copy libicuuc.so.18* and libicui18n.so.18* to $(prefix)/lib directory, together with current libraries).
+3. Should work on other Unixes.
+
Change $ICU_PREFIX to point to the current installation, and $ICU_LEGACY to point to 1.8.1 installation. $ICU_LEGACY is needed solely to access the 1.8.1 include directory through $LEGACY_INCLUDE variable, so if you want to move the 1.8.1. include directory, you can set $LEGACY_INCLUDE directly to that directory.
@@ -34,3 +37,4 @@
Linker says: "Undefined symbol u_getVersion()" (or something similar): path to 1.8.1. libraries is bad.
Linker says: "Undefined symbol u_getVersion()_X_Y" (or something similar): path to current libraries is bad.
Legacy crashes horribly: Sorry, didn't put any error checking. If legacy crashes that's most probably because it cannot find the data libraries. You can see which data library is not found by the part of the program that is running. Make sure program can find tha data library either by putting it where ever ICU_DATA points to OR by putting the DLL version of the data library somewhere on your PATH.
+
diff --git a/icu4c/source/samples/legacy/oldcol.cpp b/icu4c/source/samples/legacy/oldcol.cpp
index 87e2dc6..24ced03 100644
--- a/icu4c/source/samples/legacy/oldcol.cpp
+++ b/icu4c/source/samples/legacy/oldcol.cpp
@@ -57,10 +57,25 @@
void initCollator_legacy(const char *locale) {
UErrorCode status = U_ZERO_ERROR;
compareCollator = ucol_open(locale, &status);
+
+ if(U_FAILURE(status))
+ {
+ fprintf(stderr, "initCollator_legacy(%s): error opening collator, %s!\n", locale, u_errorName(status));
+ fprintf(stderr, "Note: ICU data directory is %s\n", u_getDataDirectory());
+ fprintf(stderr, "Read the README!\n");
+ exit(0);
+ }
}
void closeCollator_legacy(void) {
- ucol_close(compareCollator);
+ if(compareCollator != NULL)
+ {
+ ucol_close(compareCollator);
+ }
+ else
+ {
+ fprintf(stderr, "closeCollator_legacy(): collator was already NULL!\n");
+ }
compareCollator = NULL;
}
diff --git a/icu4c/source/samples/msgfmt/Makefile b/icu4c/source/samples/msgfmt/Makefile
index 931879f..a46445d 100644
--- a/icu4c/source/samples/msgfmt/Makefile
+++ b/icu4c/source/samples/msgfmt/Makefile
@@ -7,7 +7,7 @@
# - do 'make install' of icu
#
# - change the following line to point to the $(prefix) that
-# was used (will look for $(prefix)/lib/icu/Makefile.inc )
+# was used (will look for $(prefix)/share/icu/Makefile.inc )
# OR
# set the variable ICU_PREFIX to point at $(prefix)
#
@@ -50,7 +50,7 @@
# Make check: simply runs the sample, logged to a file
check: $(TARGET)
- $(TARGET) | tee $(TARGET).out
+ $(INVOKE) ./$(TARGET) | tee $(TARGET).out
# Make report: creates a 'report file' with both source and sample run
report: $(TARGET).report
@@ -59,7 +59,7 @@
more $(TARGET).cpp $(TARGET).out > $@
$(ICU_INC):
- @echo "Please read the directions at the top of this file (Makefile)"
+ @echo "Please read the directions at the top of this file (Makefile) and the README"
@echo "Can't open $(ICU_INC)"
@false
diff --git a/icu4c/source/samples/msgfmt/README.TXT b/icu4c/source/samples/msgfmt/README.TXT
index 1d73e19..ba79b85 100644
--- a/icu4c/source/samples/msgfmt/README.TXT
+++ b/icu4c/source/samples/msgfmt/README.TXT
@@ -1,7 +1,9 @@
This is an exercise for the ICU Workshop (September 2000).
+ http://oss.software.ibm.com/icu/docs/workshop_2000/agenda.html
+
Day 2: September 12th 2000
- Pre-requsit:
+ Pre-requisites:
1. All the hardware and software requirements from Day 1.
2. Attended or fully understand Day 1 material.
3. Read through the ICU user's guide at
@@ -21,24 +23,19 @@
INSTRUCTIONS
------------
-This exercise was developed and tested on ICU release 1.6.0, Win32,
+
+This exercise was first developed and tested on ICU release 1.6.0, Win32,
Microsoft Visual C++ 6.0. It should work on other ICU releases and
other platforms as well.
-To install: Create a folder "datefmt" at:
+ MSVC:
+ Open the file "msgfmt.dsw" in Microsoft Visual C++.
- <icu>/source/samples/msgfmt
-
-Within it, place the files:
-
- msgfmt.dsp
- msgfmt.dsw
- main.cpp
- util.cpp
- util.h
-
-Open the file "msgfmt.dsw" in Microsoft Visual C++.
-
+ Unix:
+ - Build and install ICU with a prefix, for example '--prefix=/home/srl/ICU'
+ - Set the variable ICU_PREFIX=/home/srl/ICU and use GNU make in
+ this directory.
+ - You may use 'make check' to invoke this sample.
PROBLEMS
--------
diff --git a/icu4c/source/samples/numfmt/Makefile b/icu4c/source/samples/numfmt/Makefile
index 38ce58b..59337ee 100644
--- a/icu4c/source/samples/numfmt/Makefile
+++ b/icu4c/source/samples/numfmt/Makefile
@@ -50,7 +50,7 @@
# Make check: simply runs the sample, logged to a file
check: $(TARGET)
- $(INVOKE) $(TARGET) | tee $(TARGET).out
+ $(INVOKE) ./$(TARGET) | tee $(TARGET).out
# Make report: creates a 'report file' with both source and sample run
report: $(TARGET).report
diff --git a/icu4c/source/samples/numfmt/readme.txt b/icu4c/source/samples/numfmt/readme.txt
index 6e01e66..b513895 100644
--- a/icu4c/source/samples/numfmt/readme.txt
+++ b/icu4c/source/samples/numfmt/readme.txt
@@ -29,7 +29,7 @@
numfmt
To Build on Unixes
- 1. Build ICU. numfmt is built automatically by default unless samples are turned off.
+ 1. Build ICU.
Specify an ICU install directory when running configure,
using the --prefix option. The steps to build ICU will look something
like this:
@@ -53,7 +53,6 @@
export LD_LIBRARY_PATH=<icu install directory>/lib:.:$LD_LIBRARY_PATH
numfmt
-
Note: The name of the LD_LIBRARY_PATH variable is different on some systems.
If in doubt, run the sample using "gmake check", and note the name of
the variable that is used there. LD_LIBRARY_PATH is the correct name
diff --git a/icu4c/source/samples/props/Makefile b/icu4c/source/samples/props/Makefile
new file mode 100644
index 0000000..3802506
--- /dev/null
+++ b/icu4c/source/samples/props/Makefile
@@ -0,0 +1,68 @@
+# Copyright (c) 2000 IBM, Inc. and others
+
+# Usage:
+# - configure and build ICU [see the docs] .. use "--prefix=" something
+# (I used --prefix=/home/srl/III )
+#
+# - do 'make install' of icu
+#
+# - change the following line to point to the $(prefix) that
+# was used (will look for $(prefix)/share/icu/Makefile.inc )
+# OR
+# set the variable ICU_PREFIX to point at $(prefix)
+#
+# - do 'make' in this directory
+
+ICU_DEFAULT_PREFIX=~/icu
+
+ifeq ($(strip $(ICU_PREFIX)),)
+ ICU_INC=$(ICU_DEFAULT_PREFIX)/lib/icu/Makefile.inc
+else
+ ICU_INC=$(ICU_PREFIX)/lib/icu/Makefile.inc
+endif
+ICUPATH=
+
+include $(ICU_INC)
+
+# Name of your target
+TARGET=props
+
+# All object files (C or C++)
+OBJECTS=props.o
+
+CLEANFILES=*~ $(TARGET).out
+
+DEPS=$(OBJECTS:.o=.d)
+
+all: $(TARGET)
+
+.PHONY: all clean distclean check report
+
+distclean clean:
+ -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
+ -$(RMV) $(OBJECTS) $(TARGET)
+ -$(RMV) $(DEPS)
+
+# Can change this to LINK.c if it is a C only program
+# Can add more libraries here.
+$(TARGET): $(OBJECTS)
+ $(LINK.cc) -o $@ $^ $(ICULIBS)
+
+# Make check: simply runs the sample, logged to a file
+check: $(TARGET)
+ $(INVOKE) ./$(TARGET) | tee $(TARGET).out
+
+# Make report: creates a 'report file' with both source and sample run
+report: $(TARGET).report
+
+$(TARGET).report: check $(TARGET).cpp
+ more $(TARGET).cpp $(TARGET).out > $@
+
+$(ICU_INC):
+ @echo "Please read the directions at the top of this file (Makefile) and the README"
+ @echo "Can't open $(ICU_INC)"
+ @false
+
+ifneq ($(MAKECMDGOALS),distclean)
+-include $(DEPS)
+endif
diff --git a/icu4c/source/samples/props/props.cpp b/icu4c/source/samples/props/props.cpp
index ef13a88..f60f26a 100644
--- a/icu4c/source/samples/props/props.cpp
+++ b/icu4c/source/samples/props/props.cpp
@@ -51,7 +51,7 @@
main(int argc, const char *argv[]) {
static const UChar32
codePoints[]={
- 0xd, 0x20, 0x2d, 0x35, 0x65, 0x284, 0x665, 0x5678, 0x23456, 0x10fffd
+ 0xd, 0x20, 0x2d, 0x35, 0x65, 0x284, 0x665, 0x5678, 0x23456, 0x10317, 0x1D01F, 0x10fffd
};
int i;
diff --git a/icu4c/source/samples/props/readme.txt b/icu4c/source/samples/props/readme.txt
new file mode 100644
index 0000000..f8c62d8
--- /dev/null
+++ b/icu4c/source/samples/props/readme.txt
@@ -0,0 +1,58 @@
+props: Unicode Character Properties
+
+This sample demonstrates
+ Using ICU to determine the properties of Unicode characters
+
+
+Files:
+ props.cpp Main source file in C++
+ props.dsw Windows MSVC workspace. Double-click this to get started.
+ props.dsp Windows MSVC project file
+
+To Build props on Windows
+ 1. Install and build ICU
+ 2. In MSVC, open the workspace file icu\samples\props\props.dsw
+ 3. Choose a Debug or Release build.
+ 4. Build.
+
+To Run on Windows
+ 1. Start a command shell window
+ 2. Add ICU's bin directory to the path, e.g.
+ set PATH=c:\icu\bin;%PATH%
+ (Use the path to where ever ICU is on your system.)
+ 3. cd into the props directory, e.g.
+ cd c:\icu\source\samples\props\debug
+ 4. Run it
+ props
+
+To Build on Unixes
+ 1. Build ICU.
+ Specify an ICU install directory when running configure,
+ using the --prefix option. The steps to build ICU will look something
+ like this:
+ cd <icu directory>/source
+ runConfigureICU <platform-name> --prefix <icu install directory> [other options]
+ gmake all
+
+ 2. Install ICU,
+ gmake install
+
+ 3. Compile
+ cd <icu directory>/source/samples/props
+ gmake ICU_PREFIX=<icu install directory)
+
+ To Run on Unixes
+ cd <icu directory>/source/samples/props
+
+ gmake ICU_PREFIX=<icu install directory> check
+ -or-
+
+ export LD_LIBRARY_PATH=<icu install directory>/lib:.:$LD_LIBRARY_PATH
+ props
+
+
+ Note: The name of the LD_LIBRARY_PATH variable is different on some systems.
+ If in doubt, run the sample using "gmake check", and note the name of
+ the variable that is used there. LD_LIBRARY_PATH is the correct name
+ for Linux and Solaris.
+
diff --git a/icu4c/source/samples/readme.txt b/icu4c/source/samples/readme.txt
new file mode 100644
index 0000000..096b4c8
--- /dev/null
+++ b/icu4c/source/samples/readme.txt
@@ -0,0 +1,45 @@
+## Copyright (c) 2002, International Business Machines Corporation
+## and others. All Rights Reserved.
+
+This directory contains sample code
+Below is a short description of the contents of this directory.
+
+cal - prints out a calendar.
+
+date - prints out the current date, localized.
+
+datefmt - an exercise using the date formatting API
+
+layout - demonstrates the ICU layout engine
+
+legacy - demonstrates using two versions of ICU in one application
+
+msgfmt - demonstrates the use of the Message Format
+
+numfmt - demonstrates the use of the number format
+
+props - demonstrates the use of Unicode properties
+
+translit - demonstrates the use of ICU transliteration
+
+ucnv - demonstrates the use of ICU codepage conversion
+
+udata - demonstrates the use of ICU low level data routines
+
+ufortune - demonstrates packaging and use of resources in an application
+
+uresb - demonstrates building and loading resource bundles
+
+ustring - demonstrates ICU string manipulation functions
+
+
+==
+* Where can I find more sample code?
+
+ - The "uconv" utility is a full-featured command line application.
+ It is normally built with ICU, and is located in icu/source/extra/uconv
+
+ - The "icuapps" CVS module contains other applications and libraries not
+ included with ICU. You can check it out from the CVS command line
+ by using for example, "cvs co icuapps" instead of "cvs co icu",
+ or through WebCVS at http://oss.software.ibm.com/cvs/icu/icuapps/
diff --git a/icu4c/source/samples/translit/Makefile b/icu4c/source/samples/translit/Makefile
index cba53c5..4999f8f 100644
--- a/icu4c/source/samples/translit/Makefile
+++ b/icu4c/source/samples/translit/Makefile
@@ -29,6 +29,7 @@
# All object files (C or C++)
OBJECTS=main.o util.o
+# You can simply add 'unaccent.o' to the above line for example.
CLEANFILES=*~ $(TARGET).out
@@ -50,7 +51,7 @@
# Make check: simply runs the sample, logged to a file
check: $(TARGET)
- $(TARGET) | tee $(TARGET).out
+ $(INVOKE) ./$(TARGET) | tee $(TARGET).out
# Make report: creates a 'report file' with both source and sample run
report: $(TARGET).report
diff --git a/icu4c/source/samples/translit/README.TXT b/icu4c/source/samples/translit/README.TXT
index d37e09a..8e4cfa1 100644
--- a/icu4c/source/samples/translit/README.TXT
+++ b/icu4c/source/samples/translit/README.TXT
@@ -1,4 +1,5 @@
This is an exercise for the ICU Workshop (September 2000).
+ http://oss.software.ibm.com/icu/docs/workshop_2000/agenda.html
Day 2: September 12th 2000
Pre-requisite:
@@ -25,19 +26,14 @@
Microsoft Visual C++ 6.0. It should work on other ICU releases and
other platforms as well.
-To install: Create a folder "translit" at:
+ MSVC:
+ Open the file "translit.dsw" in Microsoft Visual C++.
- <icu>/source/samples/translit
-
-Within it, place the files:
-
- translit.dsp
- translit.dsw
- main.cpp
- util.cpp
- util.h
-
-Open the file "translit.dsw" in Microsoft Visual C++.
+ Unix:
+ - Build and install ICU with a prefix, for example '--prefix=/home/srl/ICU'
+ - Set the variable ICU_PREFIX=/home/srl/ICU and use GNU make in
+ this directory.
+ - You may use 'make check' to invoke this sample.
PROBLEMS
diff --git a/icu4c/source/samples/ucnv/Makefile b/icu4c/source/samples/ucnv/Makefile
index cd0fb90..6a43991 100644
--- a/icu4c/source/samples/ucnv/Makefile
+++ b/icu4c/source/samples/ucnv/Makefile
@@ -1,5 +1,5 @@
# Copyright (c) 2000 IBM, Inc. and others
-# conversion sample code $Revision: 1.4 $
+# conversion sample code $Revision: 1.5 $
# Usage:
@@ -56,7 +56,7 @@
# Make check: simply runs the sample, logged to a file
check: $(TARGET)
- $(TARGET) | tee $(TARGET).out
+ $(INVOKE) ./$(TARGET) | tee $(TARGET).out
# Make report: creates a 'report file' with both source and sample run
report: $(TARGET).report
diff --git a/icu4c/source/samples/ucnv/readme.txt b/icu4c/source/samples/ucnv/readme.txt
new file mode 100644
index 0000000..904ee07
--- /dev/null
+++ b/icu4c/source/samples/ucnv/readme.txt
@@ -0,0 +1,62 @@
+convsamp: a sample program which demonstrates using ICU conversion
+
+This sample demonstrates
+ Opening and closing converters using the C and C++ api
+ String manipulation in C and C++
+ Writing a custom conversion callback function
+
+
+Files:
+ convsamp.c Main source file
+ flagcb.h codepage output convenience header
+ flagcb.c codepage output convenience implementation
+ ucnv.dsw Windows MSVC workspace. Double-click this to get started.
+ ucnv.dsp Windows MSVC project file
+
+To Build ucnv on Windows
+ 1. Install and build ICU
+ 2. In MSVC, open the workspace file icu\samples\ucnv\ucnv.dsw
+ 3. Choose a Debug or Release build.
+ 4. Build.
+
+To Run on Windows
+ 1. Start a command shell window
+ 2. Add ICU's bin directory to the path, e.g.
+ set PATH=c:\icu\bin;%PATH%
+ (Use the path to where ever ICU is on your system.)
+ 3. cd into the ufortune directory, e.g.
+ cd c:\icu\source\samples\ucnv\debug
+ 4. Run it
+ ucnv
+
+To Build on Unixes
+ 1. Build ICU.
+ Specify an ICU install directory when running configure,
+ using the --prefix option. The steps to build ICU will look something
+ like this:
+ cd <icu directory>/source
+ runConfigureICU <platform-name> --prefix <icu install directory> [other options]
+ gmake all
+
+ 2. Install ICU,
+ gmake install
+
+ 3. Build
+ set the variable ICU_PREFIX=<icu install>
+ gmake all
+
+ To Run on Unixes
+ cd <icu directory>/source/samples/ucnv
+
+ gmake check
+ -or-
+
+ export LD_LIBRARY_PATH=<icu install directory>/lib:.:$LD_LIBRARY_PATH
+ convsamp
+
+
+ Note: The name of the LD_LIBRARY_PATH variable is different on some systems.
+ If in doubt, run the sample using "gmake check", and note the name of
+ the variable that is used there. LD_LIBRARY_PATH is the correct name
+ for Linux and Solaris.
+
diff --git a/icu4c/source/samples/udata/Makefile b/icu4c/source/samples/udata/Makefile
index 67e55bb..b2d1b4d 100644
--- a/icu4c/source/samples/udata/Makefile
+++ b/icu4c/source/samples/udata/Makefile
@@ -1,5 +1,5 @@
# Copyright (c) 2000 IBM, Inc. and others
-# udata sample code $Revision: 1.2 $
+# udata sample code $Revision: 1.3 $
# Usage:
@@ -9,7 +9,7 @@
# - do 'make install' of icu
#
# - change ICU_DEFAULT_PREFIX line to point to the $(prefix) that
-# was used (will look for $(prefix)/share/icu/Makefile.inc )
+# was used (will look for $(prefix)/lib/icu/Makefile.inc )
# OR
# set the variable ICU_PREFIX to point at $(prefix)
#
@@ -21,12 +21,12 @@
# - do 'make' in this directory
ICU_DEFAULT_PREFIX=/home/srl/II
-ICU_DEFAULT_PATH=~/icu
+ICU_DEFAULT_PATH=$(HOME)/icu
ifeq ($(strip $(ICU_PREFIX)),)
- ICU_INC=$(ICU_DEFAULT_PREFIX)/share/icu/Makefile.inc
+ ICU_INC=$(ICU_DEFAULT_PREFIX)/lib/icu/Makefile.inc
else
- ICU_INC=$(ICU_PREFIX)/share/icu/Makefile.inc
+ ICU_INC=$(ICU_PREFIX)/lib/icu/Makefile.inc
endif
@@ -49,16 +49,20 @@
DEPS=$(OBJECTS:.o=.d)
-all: $(ICU_PATH)/source/tools/toolutil/uoptions.h $(TARGET1) $(TARGET2)
+all: $(TARGET1) $(TARGET2)
+
+writer.o: $(ICU_PATH)/source/tools/toolutil/uoptions.h
$(ICU_PATH)/source/tools/toolutil/uoptions.h:
- @echo "Please read the directions at the top of this file (Makefile)"
- @echo "Can't open $@ - check ICU_PATH"
+ @echo
+ @echo "*** Please read the directions at the top of this file (Makefile)"
+ @echo "*** Can't open $@ - check ICU_PATH"
+ @echo
@false
# Only the writer needs these, actually.
CPPFLAGS += -I$(ICU_PATH)/source/tools/toolutil
-LDFLAGS += -L$(ICU_PATH)/source/tools/toolutil -licu-toolutil
+#LDFLAGS += -L$(ICU_PATH)/source/tools/toolutil -licu-toolutil
.PHONY: all clean distclean check report
@@ -78,8 +82,8 @@
# Make check: simply runs the sample, logged to a file
check: $(TARGET1) $(TARGET2)
- $(TARGET1) | tee $(TARGET1).out
- $(TARGET2) | tee $(TARGET2).out
+ $(INVOKE) ./$(TARGET2) | tee $(TARGET2).out
+ $(INVOKE) ./$(TARGET1) | tee $(TARGET1).out
$(ICU_INC):
@echo "Please read the directions at the top of this file (Makefile)"
diff --git a/icu4c/source/samples/udata/readme.txt b/icu4c/source/samples/udata/readme.txt
new file mode 100644
index 0000000..f0c317f
--- /dev/null
+++ b/icu4c/source/samples/udata/readme.txt
@@ -0,0 +1,60 @@
+udata: Low level ICU data
+
+This sample demonstrates
+ Using the low level ICU data handling interfaces (udata) to create
+ and later access user data.
+
+Files:
+ writer.c C source for Writer application, will generate data file to be read by Reader.
+ reader.c C source for Reader application, will read file created by Writer
+ udata.dsw Windows MSVC workspace. Double-click this to get started.
+ udata.dsp Windows MSVC project file
+
+To Build udata on Windows
+ 1. Install and build ICU
+ 2. In MSVC, open the workspace file icu\samples\udata\udata.dsw
+ 3. Choose a Debug or Release build.
+ 4. Build.
+
+To Run on Windows
+ 1. Start a command shell window
+ 2. Add ICU's bin directory to the path, e.g.
+ set PATH=c:\icu\bin;%PATH%
+ (Use the path to where ever ICU is on your system.)
+ 3. cd into the udata directory, e.g.
+ cd c:\icu\source\samples\udata\debug
+ 4. Run it
+ writer
+ reader
+
+To Build on Unixes
+ 1. Build ICU.
+ Specify an ICU install directory when running configure,
+ using the --prefix option. The steps to build ICU will look something
+ like this:
+ cd <icu directory>/source
+ runConfigureICU <platform-name> --prefix <icu install directory> [other options]
+ gmake all
+
+ 2. Install ICU,
+ gmake install
+
+ 3. Compile
+ You will need to set ICU_PATH to the location of your ICU source tree, for example ICU_PATH=/home/srl/icu (containing source, etc.)
+ cd <icu directory>/source/samples/udata
+ gmake ICU_PATH=<icu source directory> ICU_PREFIX=<icu install directory)
+
+ To Run on Unixes
+ cd <icu directory>/source/samples/udata
+ gmake ICU_PREFIX=<icu install directory> check
+ -or-
+
+ export LD_LIBRARY_PATH=<icu install directory>/lib:.:$LD_LIBRARY_PATH
+ writer
+ reader
+
+ Note: The name of the LD_LIBRARY_PATH variable is different on some systems.
+ If in doubt, run the sample using "gmake check", and note the name of
+ the variable that is used there. LD_LIBRARY_PATH is the correct name
+ for Linux and Solaris.
+
diff --git a/icu4c/source/samples/ufortune/Makefile b/icu4c/source/samples/ufortune/Makefile
index 1f0f79a..e76af3f 100644
--- a/icu4c/source/samples/ufortune/Makefile
+++ b/icu4c/source/samples/ufortune/Makefile
@@ -49,7 +49,7 @@
.PHONY: all clean distclean check report subdirs $(SUBDIRS)
subdirs: $(SUBDIRS)
-
+
$(SUBDIRS):
$(MAKE) -C $@
@@ -66,7 +66,7 @@
# Make check: simply runs the sample, logged to a file
check: $(TARGET)
- $(UFINVOKE) $(TARGET) | tee $(TARGET).out
+ $(UFINVOKE) ./$(TARGET) | tee $(TARGET).out
# Make report: creates a 'report file' with both source and sample run
report: $(TARGET).report
diff --git a/icu4c/source/samples/uresb/Makefile b/icu4c/source/samples/uresb/Makefile
index 9275603..07f9428 100644
--- a/icu4c/source/samples/uresb/Makefile
+++ b/icu4c/source/samples/uresb/Makefile
@@ -1,5 +1,5 @@
# Copyright (c) 2000 IBM, Inc. and others
-# conversion sample code $Revision: 1.4 $
+# conversion sample code $Revision: 1.5 $
# Usage:
@@ -20,8 +20,8 @@
#
# - do 'make' in this directory
-ICU_DEFAULT_PREFIX=/home/weiv/build/workshop
-ICU_DEFAULT_PATH=/home/weiv/dev/icu
+ICU_DEFAULT_PREFIX=ICU_PREFIX
+ICU_DEFAULT_PATH=../../..
ifeq ($(strip $(ICU_PREFIX)),)
ICU_INC=$(ICU_DEFAULT_PREFIX)/lib/icu/Makefile.inc
@@ -50,7 +50,9 @@
DEPS=$(OBJECTS:.o=.d)
-all: $(ICU_PATH)/source/tools/toolutil/uoptions.h $(GENRB) $(RESOURCES) $(TARGET)
+all: $(GENRB) $(RESOURCES) $(TARGET)
+
+uresb.o: $(ICU_PATH)/source/tools/toolutil/uoptions.h
$(ICU_PATH)/source/tools/toolutil/uoptions.h:
@echo "Please read the directions at the top of this file (Makefile)"
@@ -74,15 +76,15 @@
## resources
root.res : root.txt
- #@echo "generating $@"
+ @echo "generating $@"
$(GENRB) $(GENRBOPT) $?
en.res : en.txt
- #@echo "generating $@"
+ @echo "generating $@"
$(GENRB) $(GENRBOPT) $?
sr.res : sr.txt
- #@echo "generating $@"
+ @echo "generating $@"
$(GENRB) $(GENRBOPT) -e cp1251 $?
@@ -93,8 +95,8 @@
$(LINK.cc) -o $@ $^ $(ICULIBS)
# Make check: simply runs the sample, logged to a file
-check: $(TARGET)
- $(TARGET) | tee $(TARGET).out
+check: $(TARGET) $(RESOURCES)
+ $(INVOKE) ./$(TARGET) en | tee $(TARGET).out
# Make report: creates a 'report file' with both source and sample run
report: $(TARGET).report
diff --git a/icu4c/source/samples/uresb/readme.txt b/icu4c/source/samples/uresb/readme.txt
new file mode 100644
index 0000000..289725e
--- /dev/null
+++ b/icu4c/source/samples/uresb/readme.txt
@@ -0,0 +1,65 @@
+uresb: Resource Bundle
+
+This sample demonstrates
+ Building a resource bundle
+ Using ICU to print data from a resource bundle
+
+
+Files:
+ uresb.c Main source file in C
+ uresb.dsw Windows MSVC workspace. Double-click this to get started.
+ uresb.dsp Windows MSVC project file
+ resources.dsp Windows project file for resources
+ resources.mak Windows makefile for resources
+
+ root.txt Root resource bundle
+ en.txt English translation
+ sr.txt Serbian translation (cp1251)
+
+To Build uresb on Windows
+ 1. Install and build ICU
+ 2. In MSVC, open the workspace file icu\samples\uresb\uresb.dsw
+ 3. Choose a Debug or Release build.
+ 4. Build.
+
+To Run on Windows
+ 1. Start a command shell window
+ 2. Add ICU's bin directory to the path, e.g.
+ set PATH=c:\icu\bin;%PATH%
+ (Use the path to where ever ICU is on your system.)
+ 3. cd into the uresb directory, e.g.
+ cd c:\icu\source\samples\uresb\debug
+ 4. Run it (with a locale name, ex. english)
+ uresb en
+
+To Build on Unixes
+ 1. Build ICU.
+ Specify an ICU install directory when running configure,
+ using the --prefix option. The steps to build ICU will look something
+ like this:
+ cd <icu directory>/source
+ runConfigureICU <platform-name> --prefix <icu install directory> [other options]
+ gmake all
+
+ 2. Install ICU,
+ gmake install
+
+ 3. Compile
+ cd <icu directory>/source/samples/uresb
+ gmake ICU_PREFIX=<icu install directory) ICU_PATH=<icu source directory>
+
+ To Run on Unixes
+ cd <icu directory>/source/samples/uresb
+
+ gmake ICU_PREFIX=<icu install directory> check
+ -or-
+
+ export LD_LIBRARY_PATH=<icu install directory>/lib:.:$LD_LIBRARY_PATH
+ uresb
+
+
+ Note: The name of the LD_LIBRARY_PATH variable is different on some systems.
+ If in doubt, run the sample using "gmake check", and note the name of
+ the variable that is used there. LD_LIBRARY_PATH is the correct name
+ for Linux and Solaris.
+
diff --git a/icu4c/source/samples/ustring/Makefile b/icu4c/source/samples/ustring/Makefile
index 745c910..f6d8b7e 100644
--- a/icu4c/source/samples/ustring/Makefile
+++ b/icu4c/source/samples/ustring/Makefile
@@ -1,5 +1,5 @@
# Copyright (c) 2000 IBM, Inc. and others
-# conversion sample code $Revision: 1.2 $
+# conversion sample code $Revision: 1.3 $
# Usage:
@@ -52,7 +52,7 @@
# Make check: simply runs the sample, logged to a file
check: $(TARGET)
- $(TARGET) | tee $(TARGET).out
+ $(INVOKE) ./$(TARGET) | tee $(TARGET).out
# Make report: creates a 'report file' with both source and sample run
report: $(TARGET).report
diff --git a/icu4c/source/samples/ustring/readme.txt b/icu4c/source/samples/ustring/readme.txt
new file mode 100644
index 0000000..2d31770
--- /dev/null
+++ b/icu4c/source/samples/ustring/readme.txt
@@ -0,0 +1,59 @@
+ustring: Unicode String Manipulation
+
+This sample demonstrates
+ Using ICU to manipulate UnicodeString objects
+
+
+Files:
+ ustring.cpp Main source file in C++
+ ustring.dsw Windows MSVC workspace. Double-click this to get started.
+ ustring.dsp Windows MSVC project file
+
+To Build ustring on Windows
+ 1. Install and build ICU
+ 2. In MSVC, open the workspace file icu\samples\ustring\ustring.dsw
+ 3. Choose a Debug or Release build.
+ 4. Build.
+
+To Run on Windows
+ 1. Start a command shell window
+ 2. Add ICU's bin directory to the path, e.g.
+ set PATH=c:\icu\bin;%PATH%
+ (Use the path to where ever ICU is on your system.)
+ 3. cd into the ustring directory, e.g.
+ cd c:\icu\source\samples\ustring\debug
+ 4. Run it
+ ustring
+
+To Build on Unixes
+ 1. Build ICU.
+ Specify an ICU install directory when running configure,
+ using the --prefix option. The steps to build ICU will look something
+ like this:
+ cd <icu directory>/source
+ runConfigureICU <platform-name> --prefix <icu install directory> [other options]
+ gmake all
+
+ 2. Install ICU,
+ gmake install
+
+ 3. Compile
+ cd <icu directory>/source/samples/ustring
+ gmake ICU_PREFIX=<icu install directory)
+
+ To Run on Unixes
+ cd <icu directory>/source/samples/ustring
+
+ gmake ICU_PREFIX=<icu install directory> check
+ -or-
+
+ export LD_LIBRARY_PATH=<icu install directory>/lib:.:$LD_LIBRARY_PATH
+ ustring
+
+
+ Note: The name of the LD_LIBRARY_PATH variable is different on some systems.
+ If in doubt, run the sample using "gmake check", and note the name of
+ the variable that is used there. LD_LIBRARY_PATH is the correct name
+ for Linux and Solaris.
+
+