aboutsummaryrefslogtreecommitdiff
path: root/iconvdata
diff options
context:
space:
mode:
Diffstat (limited to 'iconvdata')
-rw-r--r--iconvdata/Makefile2
-rw-r--r--iconvdata/TESTS26
-rw-r--r--iconvdata/big5.c8
-rw-r--r--iconvdata/iso8859-1.c4
-rwxr-xr-xiconvdata/run-iconv-test.sh39
-rw-r--r--iconvdata/testdata/suntzus1693
6 files changed, 1740 insertions, 32 deletions
diff --git a/iconvdata/Makefile b/iconvdata/Makefile
index 69576859ec..c590ab20b4 100644
--- a/iconvdata/Makefile
+++ b/iconvdata/Makefile
@@ -211,7 +211,7 @@ endif
include ../Rules
.PHONY: do-iconv-test
-#tests: do-iconv-test
+tests: do-iconv-test
do-iconv-test: run-iconv-test.sh $(objpfx)gconv-modules \
$(addprefix $(objpfx),$(modules.so)) \
diff --git a/iconvdata/TESTS b/iconvdata/TESTS
index 41d7edcaf1..c37381e70d 100644
--- a/iconvdata/TESTS
+++ b/iconvdata/TESTS
@@ -18,22 +18,24 @@
# write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
-# Each line consists of at least three entries:
+# Each line consists of at least four entries:
# 1. input file name.
# 2. output file name; this is different from the input file name only for
# conversions which do not produce the same output when the transformation
# is applied back and forth.
-# 3.
+# 3. Y or N depending of whether the character set contains ASCII as a
+# subset or not.
+# 4.
# ...
# N. target coded character set.
-ISO-8859-1 ISO-8859-1 UTF8
-ISO-8859-2 ISO-8859-2 UCS4 UTF8
-ISO-8859-3 ISO-8859-3 UTF8
-ISO-8859-4 ISO-8859-4 UTF8
-ISO-8859-5 ISO-8859-5 UTF8
-ISO-8859-6 ISO-8859-6 UTF8
-ISO-8859-7 ISO-8859-7 UTF8
-ISO-8859-8 ISO-8859-8 UTF8
-ISO-8859-9 ISO-8859-9 UTF8
-ISO-8859-10 ISO-8859-10 UCS2 UTF8
+ISO-8859-1 ISO-8859-1 Y UTF8
+ISO-8859-2 ISO-8859-2 Y UCS4 UTF8
+ISO-8859-3 ISO-8859-3 Y UTF8
+ISO-8859-4 ISO-8859-4 Y UTF8
+ISO-8859-5 ISO-8859-5 Y UTF8
+ISO-8859-6 ISO-8859-6 Y UTF8
+ISO-8859-7 ISO-8859-7 Y UTF8
+ISO-8859-8 ISO-8859-8 Y UTF8
+ISO-8859-9 ISO-8859-9 Y UTF8
+ISO-8859-10 ISO-8859-10 Y UCS2 UTF8
diff --git a/iconvdata/big5.c b/iconvdata/big5.c
index 2962712167..d4d89a04ff 100644
--- a/iconvdata/big5.c
+++ b/iconvdata/big5.c
@@ -8431,7 +8431,7 @@ static const char from_ucs4_tab13[][2] =
{ \
uint32_t ch = *inptr; \
\
- if (ch >= '\xa1' && ch <= '\xff') \
+ if (ch >= 0xa1 && ch <= 0xff) \
{ \
/* Two-byte character. First test whether the next character \
is also available. */ \
@@ -8448,9 +8448,9 @@ static const char from_ucs4_tab13[][2] =
idx = (ch - 0xa1) * 157; \
ch2 = inptr[1]; \
/* See whether the second byte is in the correct range. */ \
- if (ch2 >= '\x40' && ch2 <= '\x7e') \
+ if (ch2 >= 0x40 && ch2 <= 0x7e) \
idx += ch2 - 0x40; \
- else if (ch2 >= '\xa1' && ch2 <= '\xfe') \
+ else if (ch2 >= 0xa1 && ch2 <= 0xfe) \
idx += 0x3f + (ch2 - 0xa1); \
else \
{ \
@@ -8463,7 +8463,7 @@ static const char from_ucs4_tab13[][2] =
ch = big5_to_ucs[idx]; \
\
/* Is this character defined? */ \
- if (ch == L'\0' && *inptr != '\0') \
+ if (ch == 0 && *inptr != '\0') \
{ \
/* This is an illegal character. */ \
result = GCONV_ILLEGAL_INPUT; \
diff --git a/iconvdata/iso8859-1.c b/iconvdata/iso8859-1.c
index 3e50b79f17..c7b35b37dc 100644
--- a/iconvdata/iso8859-1.c
+++ b/iconvdata/iso8859-1.c
@@ -39,8 +39,8 @@
/* Next, define the other direction. */
-#define MIN_NEEDED_INPUT MIN_NEEDED_FROM
-#define MIN_NEEDED_OUTPUT MIN_NEEDED_TO
+#define MIN_NEEDED_INPUT MIN_NEEDED_TO
+#define MIN_NEEDED_OUTPUT MIN_NEEDED_FROM
#define LOOPFCT TO_LOOP
#define BODY \
{ \
diff --git a/iconvdata/run-iconv-test.sh b/iconvdata/run-iconv-test.sh
index af6a136c4a..45061373cf 100755
--- a/iconvdata/run-iconv-test.sh
+++ b/iconvdata/run-iconv-test.sh
@@ -37,37 +37,50 @@ ICONV="$codir/elf/ld.so --library-path $codir $codir/iconv/iconv_prog"
# We read the file named TESTS. All non-empty lines not starting with
# `#' are interpreted as commands.
-while read from to targets; do
+failed=0
+while read from to subset targets; do
# Ignore empty and comment lines.
if test -z "$targets" || test "$from" = '#'; then continue; fi
for t in $targets; do
$ICONV -f $from -t $t testdata/$from > $temp1 ||
- { echo "*** conversion from $from to $t failed"; exit 1; }
+ { echo "*** conversion from $from to $t failed"; failed=1; }
if test -s testdata/$from..$t; then
cmp $temp1 testdata/$from..$t >& /dev/null ||
- { echo "*** $from -> $t conversion failed"; exit 1; }
+ { echo "*** $from -> $t conversion failed"; failed=1; }
fi
$ICONV -f $t -t $to -o $temp2 $temp1 ||
- { echo "*** conversion from $t to $to failed"; exit 1; }
+ { echo "*** conversion from $t to $to failed"; failed=1; }
test -s $temp1 && cmp testdata/$from $temp2 >& /dev/null ||
- { echo "*** $from -> t -> $to conversion failed"; exit 1; }
+ { echo "*** $from -> t -> $to conversion failed"; failed=1; }
rm -f $temp1 $temp2
- # Now test some bigger text, entirely in ASCII.
- $ICONV -f $from -t $t testdata/suntzus |
- $ICONV -f $t -t $to > $temp1 ||
- { echo "*** conversion $from->$t->$to of suntzus failed"; exit 1; }
- cmp testdata/suntzus.txt $temp1 ||
- { echo "*** conversion $from->$t->$to of suntzus incorrect"; exit 1; }
+ # Now test some bigger text, entirely in ASCII. If ASCII is no subset
+ # of the coded character set we test we convert the test to this
+ # coded character set. Otherwise we convert to all the TARGETS.
+ if test $subset = Y; then
+ $ICONV -f $from -t $t testdata/suntzus |
+ $ICONV -f $t -t $to > $temp1 ||
+ { echo "*** conversion $from->$t->$to of suntzus failed"; failed=1; }
+ cmp testdata/suntzus $temp1 ||
+ { echo "*** conversion $from->$t->$to of suntzus incorrect";
+ failed=1; }
+ else
+ $ICONV -f ASCII -t $to testdata/suntzus |
+ $ICONV -f $to -f ASCII > $temp1 ||
+ { echo "*** conversion ASCII->$to->ASCII of suntzus failed";
+ failed=1; }
+ cmp testdata/suntzus $temp1 ||
+ { echo "*** conversion ASCII->$to->ASCII of suntzus incorrect";
+ failed=1; }
+ fi
rm -f $temp1
-
# All tests ok.
echo "$from -> $t -> $to ok"
done
done < TESTS
-exit $?
+exit $failed
# Local Variables:
# mode:shell-script
# End:
diff --git a/iconvdata/testdata/suntzus b/iconvdata/testdata/suntzus
new file mode 100644
index 0000000000..4432c05674
--- /dev/null
+++ b/iconvdata/testdata/suntzus
@@ -0,0 +1,1693 @@
+
+
+
+
+ SUN TZU ON THE ART OF WAR
+ THE OLDEST MILITARY TREATISE IN THE WORLD
+
+ Translated from the Chinese
+ By LIONEL GILES, M.A. (1910)
+
+
+
+[This is the basic text of Sun Tzu on the Art of War. It was
+extracted from Mr. Giles' complete work as titled above. The
+commentary itself, which, of course includes this work embedded
+within it, has been released as suntzu10.txt (or suntzu10.zip).
+This is being released only as an adjunct to that work, which
+contains a wealth of commentary upon this text.]
+
+
+
+
+I. LAYING PLANS
+
+
+ 1. Sun Tzu said: The art of war is of vital importance
+ to the State.
+
+ 2. It is a matter of life and death, a road either
+ to safety or to ruin. Hence it is a subject of inquiry
+ which can on no account be neglected.
+
+ 3. The art of war, then, is governed by five constant
+ factors, to be taken into account in one's deliberations,
+ when seeking to determine the conditions obtaining in the field.
+
+ 4. These are: (1) The Moral Law; (2) Heaven; (3) Earth;
+ (4) The Commander; (5) Method and discipline.
+
+5,6. The Moral Law causes the people to be in complete
+ accord with their ruler, so that they will follow him
+ regardless of their lives, undismayed by any danger.
+
+ 7. Heaven signifies night and day, cold and heat,
+ times and seasons.
+
+ 8. Earth comprises distances, great and small;
+ danger and security; open ground and narrow passes;
+ the chances of life and death.
+
+ 9. The Commander stands for the virtues of wisdom,
+ sincerely, benevolence, courage and strictness.
+
+10. By method and discipline are to be understood
+ the marshaling of the army in its proper subdivisions,
+ the graduations of rank among the officers, the maintenance
+ of roads by which supplies may reach the army, and the
+ control of military expenditure.
+
+11. These five heads should be familiar to every general:
+ he who knows them will be victorious; he who knows them
+ not will fail.
+
+12. Therefore, in your deliberations, when seeking
+ to determine the military conditions, let them be made
+ the basis of a comparison, in this wise:--
+
+13. (1) Which of the two sovereigns is imbued
+ with the Moral law?
+ (2) Which of the two generals has most ability?
+ (3) With whom lie the advantages derived from Heaven
+ and Earth?
+ (4) On which side is discipline most rigorously enforced?
+ (5) Which army is stronger?
+ (6) On which side are officers and men more highly trained?
+ (7) In which army is there the greater constancy
+ both in reward and punishment?
+
+14. By means of these seven considerations I can
+ forecast victory or defeat.
+
+15. The general that hearkens to my counsel and acts
+ upon it, will conquer: let such a one be retained in command!
+ The general that hearkens not to my counsel nor acts upon it,
+ will suffer defeat:--let such a one be dismissed!
+
+16. While heading the profit of my counsel,
+ avail yourself also of any helpful circumstances
+ over and beyond the ordinary rules.
+
+17. According as circumstances are favorable,
+ one should modify one's plans.
+
+18. All warfare is based on deception.
+
+19. Hence, when able to attack, we must seem unable;
+ when using our forces, we must seem inactive; when we
+ are near, we must make the enemy believe we are far away;
+ when far away, we must make him believe we are near.
+
+20. Hold out baits to entice the enemy. Feign disorder,
+ and crush him.
+
+21. If he is secure at all points, be prepared for him.
+ If he is in superior strength, evade him.
+
+22. If your opponent is of choleric temper, seek to
+ irritate him. Pretend to be weak, that he may grow arrogant.
+
+23. If he is taking his ease, give him no rest.
+ If his forces are united, separate them.
+
+24. Attack him where he is unprepared, appear where
+ you are not expected.
+
+25. These military devices, leading to victory,
+ must not be divulged beforehand.
+
+26. Now the general who wins a battle makes many
+ calculations in his temple ere the battle is fought.
+ The general who loses a battle makes but few
+ calculations beforehand. Thus do many calculations
+ lead to victory, and few calculations to defeat:
+ how much more no calculation at all! It is by attention
+ to this point that I can foresee who is likely to win or lose.
+
+
+II. WAGING WAR
+
+
+ 1. Sun Tzu said: In the operations of war,
+ where there are in the field a thousand swift chariots,
+ as many heavy chariots, and a hundred thousand
+ mail-clad soldiers, with provisions enough to carry them
+ a thousand li, the expenditure at home and at the front,
+ including entertainment of guests, small items such as
+ glue and paint, and sums spent on chariots and armor,
+ will reach the total of a thousand ounces of silver per day.
+ Such is the cost of raising an army of 100,000 men.
+
+ 2. When you engage in actual fighting, if victory
+ is long in coming, then men's weapons will grow dull and
+ their ardor will be damped. If you lay siege to a town,
+ you will exhaust your strength.
+ 3. Again, if the campaign is protracted, the resources
+ of the State will not be equal to the strain.
+
+ 4. Now, when your weapons are dulled, your ardor damped,
+ your strength exhausted and your treasure spent,
+ other chieftains will spring up to take advantage
+ of your extremity. Then no man, however wise,
+ will be able to avert the consequences that must ensue.
+
+ 5. Thus, though we have heard of stupid haste in war,
+ cleverness has never been seen associated with long delays.
+
+ 6. There is no instance of a country having benefited
+ from prolonged warfare.
+
+ 7. It is only one who is thoroughly acquainted
+ with the evils of war that can thoroughly understand
+ the profitable way of carrying it on.
+
+ 8. The skillful soldier does not raise a second levy,
+ neither are his supply-wagons loaded more than twice.
+
+ 9. Bring war material with you from home, but forage
+ on the enemy. Thus the army will have food enough
+ for its needs.
+
+10. Poverty of the State exchequer causes an army
+ to be maintained by contributions from a distance.
+ Contributing to maintain an army at a distance causes
+ the people to be impoverished.
+
+11. On the other hand, the proximity of an army causes
+ prices to go up; and high prices cause the people's
+ substance to be drained away.
+
+12. When their substance is drained away, the peasantry
+ will be afflicted by heavy exactions.
+
+13,14. With this loss of substance and exhaustion
+ of strength, the homes of the people will be stripped bare,
+ and three-tenths of their income will be dissipated;
+ while government expenses for broken chariots, worn-out horses,
+ breast-plates and helmets, bows and arrows, spears and shields,
+ protective mantles, draught-oxen and heavy wagons,
+ will amount to four-tenths of its total revenue.
+
+15. Hence a wise general makes a point of foraging
+ on the enemy. One cartload of the enemy's provisions
+ is equivalent to twenty of one's own, and likewise
+ a single picul of his provender is equivalent to twenty
+ from one's own store.
+
+16. Now in order to kill the enemy, our men must
+ be roused to anger; that there may be advantage from
+ defeating the enemy, they must have their rewards.
+
+17. Therefore in chariot fighting, when ten or more chariots
+ have been taken, those should be rewarded who took the first.
+ Our own flags should be substituted for those of the enemy,
+ and the chariots mingled and used in conjunction with ours.
+ The captured soldiers should be kindly treated and kept.
+
+18. This is called, using the conquered foe to augment
+ one's own strength.
+
+19. In war, then, let your great object be victory,
+ not lengthy campaigns.
+
+20. Thus it may be known that the leader of armies
+ is the arbiter of the people's fate, the man on whom it
+ depends whether the nation shall be in peace or in peril.
+
+
+III. ATTACK BY STRATAGEM
+
+
+ 1. Sun Tzu said: In the practical art of war, the best
+ thing of all is to take the enemy's country whole and intact;
+ to shatter and destroy it is not so good. So, too, it is
+ better to recapture an army entire than to destroy it,
+ to capture a regiment, a detachment or a company entire
+ than to destroy them.
+
+ 2. Hence to fight and conquer in all your battles
+ is not supreme excellence; supreme excellence consists
+ in breaking the enemy's resistance without fighting.
+
+ 3. Thus the highest form of generalship is to
+ balk the enemy's plans; the next best is to prevent
+ the junction of the enemy's forces; the next in
+ order is to attack the enemy's army in the field;
+ and the worst policy of all is to besiege walled cities.
+
+ 4. The rule is, not to besiege walled cities if it
+ can possibly be avoided. The preparation of mantlets,
+ movable shelters, and various implements of war, will take
+ up three whole months; and the piling up of mounds over
+ against the walls will take three months more.
+
+ 5. The general, unable to control his irritation,
+ will launch his men to the assault like swarming ants,
+ with the result that one-third of his men are slain,
+ while the town still remains untaken. Such are the disastrous
+ effects of a siege.
+
+ 6. Therefore the skillful leader subdues the enemy's
+ troops without any fighting; he captures their cities
+ without laying siege to them; he overthrows their kingdom
+ without lengthy operations in the field.
+
+ 7. With his forces intact he will dispute the mastery
+ of the Empire, and thus, without losing a man, his triumph
+ will be complete. This is the method of attacking by stratagem.
+
+ 8. It is the rule in war, if our forces are ten
+ to the enemy's one, to surround him; if five to one,
+ to attack him; if twice as numerous, to divide our army
+ into two.
+
+ 9. If equally matched, we can offer battle;
+ if slightly inferior in numbers, we can avoid the enemy;
+ if quite unequal in every way, we can flee from him.
+
+10. Hence, though an obstinate fight may be made
+ by a small force, in the end it must be captured
+ by the larger force.
+
+11. Now the general is the bulwark of the State;
+ if the bulwark is complete at all points; the State will
+ be strong; if the bulwark is defective, the State will
+ be weak.
+
+12. There are three ways in which a ruler can bring
+ misfortune upon his army:--
+
+13. (1) By commanding the army to advance or to retreat,
+ being ignorant of the fact that it cannot obey.
+ This is called hobbling the army.
+
+14. (2) By attempting to govern an army in the
+ same way as he administers a kingdom, being ignorant
+ of the conditions which obtain in an army. This causes
+ restlessness in the soldier's minds.
+
+15. (3) By employing the officers of his army
+ without discrimination, through ignorance of the
+ military principle of adaptation to circumstances.
+ This shakes the confidence of the soldiers.
+
+16. But when the army is restless and distrustful,
+ trouble is sure to come from the other feudal princes.
+ This is simply bringing anarchy into the army, and flinging
+ victory away.
+
+17. Thus we may know that there are five essentials
+ for victory:
+ (1) He will win who knows when to fight and when
+ not to fight.
+ (2) He will win who knows how to handle both superior
+ and inferior forces.
+ (3) He will win whose army is animated by the same
+ spirit throughout all its ranks.
+ (4) He will win who, prepared himself, waits to take
+ the enemy unprepared.
+ (5) He will win who has military capacity and is
+ not interfered with by the sovereign.
+
+18. Hence the saying: If you know the enemy
+ and know yourself, you need not fear the result of a
+ hundred battles. If you know yourself but not the enemy,
+ for every victory gained you will also suffer a defeat.
+ If you know neither the enemy nor yourself, you will
+ succumb in every battle.
+
+
+IV. TACTICAL DISPOSITIONS
+
+
+ 1. Sun Tzu said: The good fighters of old first put
+ themselves beyond the possibility of defeat, and then
+ waited for an opportunity of defeating the enemy.
+
+ 2. To secure ourselves against defeat lies in our
+ own hands, but the opportunity of defeating the enemy
+ is provided by the enemy himself.
+ 3. Thus the good fighter is able to secure himself against defeat,
+ but cannot make certain of defeating the enemy.
+
+ 4. Hence the saying: One may know how to conquer
+ without being able to do it.
+
+ 5. Security against defeat implies defensive tactics;
+ ability to defeat the enemy means taking the offensive.
+
+ 6. Standing on the defensive indicates insufficient
+ strength; attacking, a superabundance of strength.
+
+ 7. The general who is skilled in defense hides in the
+ most secret recesses of the earth; he who is skilled in
+ attack flashes forth from the topmost heights of heaven.
+ Thus on the one hand we have ability to protect ourselves;
+ on the other, a victory that is complete.
+
+ 8. To see victory only when it is within the ken
+ of the common herd is not the acme of excellence.
+
+ 9. Neither is it the acme of excellence if you fight
+ and conquer and the whole Empire says, "Well done!"
+
+10. To lift an autumn hair is no sign of great strength;
+ to see the sun and moon is no sign of sharp sight;
+ to hear the noise of thunder is no sign of a quick ear.
+
+11. What the ancients called a clever fighter is
+ one who not only wins, but excels in winning with ease.
+
+12. Hence his victories bring him neither reputation
+ for wisdom nor credit for courage.
+
+13. He wins his battles by making no mistakes.
+ Making no mistakes is what establishes the certainty
+ of victory, for it means conquering an enemy that is
+ already defeated.
+
+14. Hence the skillful fighter puts himself into
+ a position which makes defeat impossible, and does
+ not miss the moment for defeating the enemy.
+
+15. Thus it is that in war the victorious strategist
+ only seeks battle after the victory has been won,
+ whereas he who is destined to defeat first fights
+ and afterwards looks for victory.
+
+16. The consummate leader cultivates the moral law,
+ and strictly adheres to method and discipline; thus it is
+ in his power to control success.
+
+17. In respect of military method, we have,
+ firstly, Measurement; secondly, Estimation of quantity;
+ thirdly, Calculation; fourthly, Balancing of chances;
+ fifthly, Victory.
+
+18. Measurement owes its existence to Earth;
+ Estimation of quantity to Measurement; Calculation to
+ Estimation of quantity; Balancing of chances to Calculation;
+ and Victory to Balancing of chances.
+
+19. A victorious army opposed to a routed one, is as
+ a pound's weight placed in the scale against a single grain.
+
+20. The onrush of a conquering force is like the bursting
+ of pent-up waters into a chasm a thousand fathoms deep.
+
+
+V. ENERGY
+
+
+ 1. Sun Tzu said: The control of a large force
+ is the same principle as the control of a few men:
+ it is merely a question of dividing up their numbers.
+
+ 2. Fighting with a large army under your command
+ is nowise different from fighting with a small one:
+ it is merely a question of instituting signs and signals.
+
+ 3. To ensure that your whole host may withstand
+ the brunt of the enemy's attack and remain unshaken--
+ this is effected by maneuvers direct and indirect.
+
+ 4. That the impact of your army may be like a grindstone
+ dashed against an egg--this is effected by the science
+ of weak points and strong.
+
+ 5. In all fighting, the direct method may be used
+ for joining battle, but indirect methods will be needed
+ in order to secure victory.
+
+ 6. Indirect tactics, efficiently applied, are inexhaustible
+ as Heaven and Earth, unending as the flow of rivers and streams;
+ like the sun and moon, they end but to begin anew;
+ like the four seasons, they pass away to return once more.
+
+ 7. There are not more than five musical notes,
+ yet the combinations of these five give rise to more
+ melodies than can ever be heard.
+
+ 8. There are not more than five primary colors
+ (blue, yellow, red, white, and black), yet in combination
+ they produce more hues than can ever been seen.
+
+ 9. There are not more than five cardinal tastes
+ (sour, acrid, salt, sweet, bitter), yet combinations
+ of them yield more flavors than can ever be tasted.
+
+10. In battle, there are not more than two methods
+ of attack--the direct and the indirect; yet these two
+ in combination give rise to an endless series of maneuvers.
+
+11. The direct and the indirect lead on to each other in turn.
+ It