这是Ada教科书的例子吗?

这是Ada教科书的例子吗?,ada,Ada,以下是“软件工程师Ada”示例程序的来源: 提取后,转到c04阵列/调整 $ gnatmake justify.adb 运行justify,并将输出与作为输入的“example.txt”进行比较。 我得到的输出是相互交织的线条,与对齐无关。 如果使用以下命令保存输出: $ justify > result.txt 然后看一下,我可以得出结论,一些行写在终端的其他行的上面。 但即使我忽略了这个问题,结果也很难被称为正当理由 我的问题: 您是否得到相同的意外输出? 您得到的输出是否类似于

以下是“软件工程师Ada”示例程序的来源:

提取后,转到c04阵列/调整

$ gnatmake justify.adb
运行justify,并将输出与作为输入的“example.txt”进行比较。 我得到的输出是相互交织的线条,与对齐无关。 如果使用以下命令保存输出:

$ justify > result.txt
然后看一下,我可以得出结论,一些行写在终端的其他行的上面。 但即使我忽略了这个问题,结果也很难被称为正当理由

我的问题: 您是否得到相同的意外输出? 您得到的输出是否类似于对齐

请注意,输入也随源一起提供!所以我甚至不想破坏这个程序

我在终端上得到的输出:

The quicke quick brown fox jumped over the lazy dog. brown fox jumped over the lazy dog. ThequickbrownfoxjumpedoverthelazydogThequickbrownfoxjumpedov The quickThe quick brown fox jumped over the lazy dog. The quick brown foxed over the lazy dog. The quick brown fox jumped over dog. The quick brown fox jumped over the lazy Thee slow gray wolf skipped over the frisky cat. The slow grayray wolf skipped over the frisky cat. The slow gray wolfed over the frisky cat. The slow gray wolf skippedky cat. The slow gray wolf skipped over the The slow gray wolf skipped over the frisky cat. 那只敏捷的棕色狐狸跳过了那只懒狗。 棕色的狐狸跳过了那只懒狗。 快速浏览信息跳转切换至快速浏览信息跳转切换至快速浏览信息跳转切换 那只敏捷的棕色狐狸跳过了那只懒狗。 那只敏捷的棕色狐狸向那只懒狗扑过去。 那只敏捷的棕色狐狸跳过了那只狗。 那只敏捷的棕色狐狸跳过了懒惰的狐狸 缓慢的灰狼跳过了那只活泼的猫。 缓慢的灰狼跳过了那只活泼的猫。 缓慢的灰色狼吞虎咽地吃着那只活泼的猫。 缓慢的灰狼跳过了这只猫。 缓慢的灰狼跳过了树林 那只缓慢的灰狼跳过了欢快的天空 猫。 重定向后的输出:

The quick brown fox jumped over the lazy dog. The quick brown fox jumped over the lazy dog. ThequickbrownfoxjumpedoverthelazydogThequickbrownfoxjumpedov The quick brown fox jumped over the lazy dog. The quick brown fox jumped over the lazy dog. The quick brown fox jumped over the lazy dog. The quick brown fox jumped over the lazy dog. The quick brown fox jumped over the lazy dog. The slow gray wolf skipped over the frisky cat. The slow gray wolf skipped over the frisky cat. The slow gray wolf skipped over the frisky cat. The slow gray wolf skipped over the frisky cat. The slow gray wolf skipped over the frisky cat. The slow gray wolf skipped over the frisky cat. The slow gray wolf skipped over the frisky cat. 那只敏捷的棕色狐狸跳过了那只懒狗。 快车 棕色的狐狸跳过了那只懒狗。 快速浏览信息跳转切换至快速浏览信息跳转切换至快速浏览信息跳转切换 那只敏捷的棕色狐狸跳过了那只懒狗。 快车 棕色的狐狸跳过了那只懒狗。 敏捷的棕色狐狸 跳过那只懒狗。 那只敏捷的棕色狐狸跳了过去 懒狗。 那只敏捷的棕色狐狸跳过了懒惰的狐狸 狗。 缓慢的灰狼跳过了那只活泼的猫。 这个 缓慢的灰狼跳过了那只活泼的猫。 缓慢的灰色 狼跳过了那只活泼的猫。 缓慢的灰狼 跳过那只活泼的猫。 缓慢的灰狼跳了起来 越过那只活泼的猫。 缓慢的灰狼跳过了树林 活泼的猫。 那只缓慢的灰狼跳过了欢快的天空 猫。 这应该是正当理由吗?
这个问题是与我的机器/系统/终端/外壳有关,还是与其他地方的问题有关?

答案可能是您的控制台使选项卡看起来像空格,从而产生不同的外观结果


您可以使用以下方法对此进行测试:

Ada.Text_IO.Put( ASCII.HT & '.' );
Ada.Text_IO.Put( ' ' & '.');

看看这两个周期是否在同一列中。

我在Mac OS X上得到了相同的输出

问题是
example.txt
是一个Windows文件,带有CR/LF行结尾,并且您运行的是Unix系统,它只需要LF;Ada RTS将CR留在每个输入线的末端。(我怀疑C RTS可能也会这样做;Python处理得更好)

中有很多信息,包括您可以使用
cat-v
查看控制字符:

      The quick brown fox jumped over the  lazy  dog.^M  The  quick
      brown     fox     jumped     over     the     lazy     dog.^M
      ThequickbrownfoxjumpedoverthelazydogThequickbrownfoxjumpedov
      The  quick  brown  fox  jumped over the lazy dog.^M The quick
      brown fox jumped over the lazy dog.^M  The  quick  brown  fox
      jumped  over  the lazy dog.^M The quick brown fox jumped over
      the lazy dog.^M The quick brown  fox  jumped  over  the  lazy
      dog.^M  The  slow gray wolf skipped over the frisky cat.^M The
      slow gray wolf skipped over the frisky cat.^M The  slow  gray
      wolf  skipped  over  the  frisky  cat.^M  The  slow gray wolf
      skipped over the frisky cat.^M The  slow  gray  wolf  skipped
      over  the  frisky  cat.^M The slow gray wolf skipped over the
      frisky cat.^M The slow gray  wolf  skipped  over  the  frisky
      cat.^M ^M 
我不知道您的系统是否有
dos2unix
实用程序,但在任何情况下,您都可以使用
tr

$ tr -d '\r' <example.txt >example.lf
$ mv example.lf example.txt
$tr-d'\r'example.lf
$mv example.lf example.txt

通常,您可以使用
unzip-a
提取归档文件,以转换原始
zip
标识为文本的所有文件的行尾;在本例中,它将所有文件都标识为二进制文件,因此您可以使用
unzip-aa
强制转换(鉴于这些都是教科书上的示例,可以相当安全地打赌其中不会有任何实际的二进制文件!)

在Windows XP上使用GNAT GPL 2012完全按照预期编译、链接和运行。