~ubuntu-branches/ubuntu/hoary/scilab/hoary

« back to all changes in this revision

Viewing changes to macros/util/format_txt.sci

  • Committer: Bazaar Package Importer
  • Author(s): Torsten Werner
  • Date: 2005-01-09 22:58:21 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20050109225821-473xr8vhgugxxx5j
Tags: 3.0-12
changed configure.in to build scilab's own malloc.o, closes: #255869

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
function [txt,space]=format_txt(txt,instr,prettyprint,nextinstr)
 
2
// Copyright INRIA
 
3
// Scilab Project - V. Couvert
 
4
// Add EOL and returns spaces to have good indentation (called by tree2code)
 
5
// Inputs:
 
6
// - txt: code to format
 
7
// - instr: instruction to evaluate as a possible EOL
 
8
// - prettyprint = %T -> code generated is formated %F -> code generated has same format as original code
 
9
// - nextinstr: next instruction after instr (format EOL between instructions)
 
10
// Outputs:
 
11
// - txt: updated txt
 
12
// - space: indentation margin for control instructions
 
13
 
 
14
rhs=argn(2)
 
15
 
 
16
// Indentation and EOL in control clauses
 
17
if rhs==3 then
 
18
  if instr<>list("EOL") & prettyprint then
 
19
    txt = cat_code(txt,"")
 
20
    space="  "
 
21
  elseif instr<>list("EOL") then
 
22
    space=" "
 
23
  else
 
24
    space="  "
 
25
  end
 
26
// EOL between instructions
 
27
else
 
28
  if prettyprint & instr<>list("EOL") & nextinstr<>list("EOL") then
 
29
    txt = cat_code(txt,"")
 
30
  end
 
31
end
 
32
endfunction