This file is indexed.

/usr/share/plplot_octave/save_fig.m is in octave-plplot 5.9.9-2ubuntu2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
## Copyright (C) 1998-2003 Joao Cardoso.
## 
## This program is free software; you can redistribute it and/or modify it
## under the terms of the GNU General Public License as published by the
## Free Software Foundation; either version 2 of the License, or (at your
## option) any later version.
## 
## This program is distributed in the hope that it will be useful, but
## WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
## General Public License for more details.
##
## This file is part of plplot_octave.

## save_fig(file, [device [, reverse]])
##
## Save current plot figure in 'file' for 'device' type.
## If reverse is 1 and the background is black, reverse black and white.
## 	(This feature has been tested with the xwin and tk driver only)
##
## If the global variable FIGDIR exists, `file' is appended to FIGDIR
## if `file' does not start with any of `/~.'
##
## The file name extension determines the device type, unless it is specified.
## Defaults are "psc" (Colour Postscript), and reverse
## The special output file `|lp' send the output to the printer.
## Use `lp_setup' to setup your printer.
##
## What is saved is all that is available in the plot buffer. To see what is
## available, type `plreplot'.
## To clear the plot buffer type `plclearplot' or `plclg'
##
## *Usual* devices are:
##	
##	ps         PostScript File (monochrome)
##	psc        PostScript File (color)
##	plmeta     PLPLOT Native Meta-File (can be displayed with 'plrender')
##	xfig       Xfig file
##	pbm        PDB (PPM) Driver
##	lj_hpgl    HP Laserjet III, HPGL emulation mode
##	hp7470     HP 7470 Plotter File (HPGL Cartridge, Small Plotter)
##	hp7580     HP 7580 Plotter File (Large Plotter)

function save_fig(file, device, rev)

  global __pl FIGDIR
  strm = __pl_init;
  
  if (plglevel != 3)
    warning("Nothing to save");
    return
  endif

  if (!exist("__pl.lp_options"))
    __pl.lp_options = "lp -c";
  endif

  if (nargin < 3)
    rev = 1;
  endif

  if (nargin < 2 )
    device = "psc";	
    ix = rindex(file, '.');
    if (ix)
      device = file(ix+1:length(file));
    endif
  endif

  ## FIXME -- this should be get from plgDevs()
  vdev = [ "xwin"; "tk"; "xterm"; "tekt"; "tek4107t"; "mskermit"; "versaterm";
	  "vlt"; "conex"; "dg300"; "plmeta"; "tekf"; "tek4107f"; "ps"; "psc";
	  "xfig"; "ljiip"; "ljii"; "hp7470"; "hp7580"; "lj_hpgl"; \
	  "imp"; "pbm"; "png"; "jpeg"; "pstex"];

  dev = "";
  for i=1:rows(vdev)
    if (strcmp(device, tdeblank(vdev(i,:))))
      dev = device;
      break;
    endif
  endfor

  if (isempty(dev))
    dev = "psc";
    warning("save_fig: Using Color Postscript.");
  endif

  device = dev;

  if (nargin >= 1 && ischar(device) & ischar(file))
    
    to_prt = 0;
    if (strcmp(file,"|lp"))	# special output file, printer!
      to_prt = 1;
      [fp,file] = mkstemp([P_tmpdir "oct_fig_XXXXXX"]);
      fclose(fp);
    elseif (file(1) == '~')
      file = tilde_expand(file);
    elseif (exist("FIGDIR") & file(1) != '/' & file(1) != '.')
      file = [FIGDIR, '/', file];
    endif

    ## see if it is possible to save the file
    [a, st] = system(sprintf("touch %s;", file),1);
    if (st != 0)
      error("Can't create file %s.\n", file);
      return;
    endif

    cur_fig = plgstrm;
    f = free_fig; # find new stream and make it default
    if (isempty(f))
      f = plmkstrm;
    endif
    
    plsstrm(f); # set stream type and output file
    plsfnam(file);
    plsdev(device);

    rev_done = 0;
    if (rev == 1) # exchange background before plinit(), if needed
      [r, g, b] = plgcolbg;
      if (r == 0 && g == 0 && b == 0)	# black background
	rev_done = 1;
	plSetOpt("bg", "FFFFFF");	# set it white
      endif
    endif

    plsetopt "apply"
    plinit;
    
    plcpstrm(cur_fig, 0); # copy parameters

    if (rev_done == 1) # and exchange black/white if needed, after plinit()
      plscol0(0, 255, 255, 255);
      plscol0(15, 0, 0, 0);
    endif

    plreplot;	# do the save
    plend1;
    plsstrm(cur_fig);	# return to previous stream

    if (to_prt == 1)
      system(sprintf("%s %s;", __pl.lp_options, file));
      unlink(file);
    endif
  else
    help save_fig
  endif	

endfunction