/usr/share/mozart/doc/op/node7.html is in mozart-doc 1.4.0-8ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>3.2 Example: Expanding TAB Characters</TITLE><LINK href="ozdoc.css" rel="stylesheet" type="text/css"></HEAD><BODY><TABLE align="center" border="0" cellpadding="6" cellspacing="6" class="nav"><TR bgcolor="#DDDDDD"><TD><A href="node6.html#section.files.basic"><< Prev</A></TD><TD><A href="node5.html">- Up -</A></TD></TR></TABLE><DIV id="section.files.expand-a"><H2><A name="section.files.expand-a">3.2 Example: Expanding TAB Characters</A></H2><P> Suppose we want to read a file, expand all <SPAN class="char">TAB</SPAN> characters to space characters, and write the expanded lines to another file. The program which implements this task is shown in <A href="node7.html#program.expand">Program 3.1</A>. </P><DIV class="program" id="program.expand"><HR><P><A name="program.expand"></A></P></DIV><DL class="anonymous"><DD class="code"><CODE><SPAN class="keyword">local</SPAN> <BR> <SPAN class="keyword">fun</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">Insert</SPAN> N Is}<BR> <SPAN class="keyword">if</SPAN> N<SPAN class="keyword">></SPAN>0 <SPAN class="keyword">then</SPAN> {Insert N<SPAN class="keyword">-</SPAN>1 <SPAN class="string">& </SPAN><SPAN class="keyword">|</SPAN>Is} <SPAN class="keyword">else</SPAN> Is <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">fun</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">Scan</SPAN> Is Tab N}<BR> <SPAN class="keyword">case</SPAN> Is <SPAN class="keyword">of</SPAN> nil <SPAN class="keyword">then</SPAN> nil<BR> <SPAN class="keyword">[]</SPAN> I<SPAN class="keyword">|</SPAN>Ir <SPAN class="keyword">then</SPAN> <BR> <SPAN class="keyword">case</SPAN> I <BR> <SPAN class="keyword">of</SPAN> <SPAN class="string">&\t</SPAN> <SPAN class="keyword">then</SPAN> M=Tab<SPAN class="keyword">-</SPAN>(N <SPAN class="keyword">mod</SPAN> Tab) <SPAN class="keyword">in</SPAN> {Insert M {Scan Ir Tab M<SPAN class="keyword">+</SPAN>N}}<BR> <SPAN class="keyword">[]</SPAN> <SPAN class="string">&\n</SPAN> <SPAN class="keyword">then</SPAN> I<SPAN class="keyword">|</SPAN>{Scan Ir Tab 0}<BR> <SPAN class="keyword">[]</SPAN> <SPAN class="string">&\b</SPAN> <SPAN class="keyword">then</SPAN> I<SPAN class="keyword">|</SPAN>{Scan Ir Tab {Max 0 N<SPAN class="keyword">-</SPAN>1}}<BR> <SPAN class="keyword">else</SPAN> I<SPAN class="keyword">|</SPAN>{Scan Ir Tab N<SPAN class="keyword">+</SPAN>1}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR><SPAN class="keyword">in</SPAN> <BR> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">Expand</SPAN> Tab IN ON}<BR> IF={New Open<SPAN class="keyword">.</SPAN>file init(name:IN)} <BR> OF={New Open<SPAN class="keyword">.</SPAN>file init(name:ON flags:[write create truncate])}<BR> Is<BR> <SPAN class="keyword">in</SPAN> <BR> {IF read(list:Is size:all)} {IF close}<BR> {OF write(vs:{Scan Is Tab 0})} {OF close}<BR> <SPAN class="keyword">end</SPAN> <BR><SPAN class="keyword">end</SPAN></CODE></DD></DL><DIV class="program"><P class="caption"><STRONG>Program 3.1:</STRONG> The <CODE>Expand</CODE> procedure.</P><HR></DIV><P> The file with name <CODE>IN</CODE> is opened for reading. After reading the entire file into the list <CODE>Is</CODE>, the file and the associated object are closed. Remember that reading the entire file is obtained by giving <CODE>all</CODE> as the value for feature <CODE>size</CODE>. </P><P> The expansion of <SPAN class="char">TAB</SPAN> characters is done in the function <CODE>Scan</CODE>. It takes as input parameters the list of characters <CODE>Is</CODE>, the <CODE>Tab</CODE>, and the current position <CODE>N</CODE> in the current line. </P><P> The outer <CODE><SPAN class="keyword">case</SPAN></CODE> of <CODE>Scan</CODE> figures out whether there are characters to process. If the next character to process is a <SPAN class="char">TAB</SPAN> character, enough space characters to reach the next multiple of <CODE>TabStop</CODE> are inserted. This is performed by the self explanatory function <CODE>Insert</CODE>. </P><P> A newline character resets the position <CODE>N</CODE> to zero. The position is decremented whenever a backspace character is encountered. Any other character increments the position. </P><P> A second file is opened for writing (indicated by <CODE>write</CODE>). If a file with name <CODE>ON</CODE> does not exist, it is created (indicated by <CODE>create</CODE>). Otherwise the already existing file is truncated to length zero (indicated by <CODE>truncate</CODE>) and rewritten. The expanded string is written to this file. </P><P> The file and its associated file object are closed after writing the expanded list of characters to it. </P></DIV><TABLE align="center" border="0" cellpadding="6" cellspacing="6" class="nav"><TR bgcolor="#DDDDDD"><TD><A href="node6.html#section.files.basic"><< Prev</A></TD><TD><A href="node5.html">- Up -</A></TD></TR></TABLE><HR><ADDRESS><A href="http://www.ps.uni-sb.de/~schulte/">Christian Schulte</A><BR><SPAN class="version">Version 1.4.0 (20110908185330)</SPAN></ADDRESS></BODY></HTML>
|