/usr/share/gnudatalanguage/lib/idl_validname.pro is in libgnudatalanguage0 0.9.6v2-1build1.
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 | ;+
;
; NAME: IDL_VALIDNAME
;
; PURPOSE:
; replacement for IDL_VALIDNAME
;
; MODIFICATION HISTORY:
; - 2010-Oct. : creation by Rene Preusker
; - 2011-Aug-18: modification by Alain Coulais :
; adding FAKE keywords /CONVERT_ALL,
; /CONVERT_SPACES for test with HealPix lib.
; - 2011-Aug-20: Alain: implement draft of CONVERT_SPACES
; - 2011-Aug: Hong Xu : implement "reserved words"
; - 2013-July: Tim : better management of "\" and "$" (patch 66)
; Alain : "!" at first place only OK; multi inputs loop
;
; LICENCE:
; Copyright (C) 2010, R. Preusker
; Copyright (C) 2011, Alain Coulais, Hong Xu
; Copyright (C) 2013, Tim, Alain Coulais
;
; 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.
;
;-
;
function IDL_VALIDNAME, in_list, $
convert_spaces=convert_spaces, $
convert_all=convert_all, $
help=help, test=test
;
if KEYWORD_SET(help) then begin
print, 'function IDL_VALIDNAME, in_list, $'
print, ' convert_spaces=convert_spaces, $'
print, ' convert_all=convert_all, $'
print, ' help=help, test=test'
return, -1
endif
;
reserved_words=['AND', $
'BEGIN', $
'BREAK', $
'CASE', $
'COMMON', $
'COMPILE_OPT', $
'CONTINUE', $
'DO', $
'ELSE', $
'END', $
'ENDCASE', $
'ENDELSE', $
'ENDFOR', $
'ENDIF', $
'ENDREP', $
'ENDSWITCH', $
'ENDWHILE', $
'EQ', $
'FOR', $
'FORWARD_FUNCTION', $
'FUNCTION', $
'GE', $
'GOTO', $
'GT', $
'IF', $
'INHERITS', $
'LE', $
'LT', $
'MOD', $
'NE', $
'NOT', $
'OF', $
'ON_IOERROR', $
'OR', $
'PRO', $
'REPEAT', $
'SWITCH', $
'THEN', $
'UNTIL', $
'WHILE', $
'XOR']
;
;; AC 03/11/2011
;; we need a working STREGEX to be able to run IDL_VALIDNAME
;; (please don't remove this test: if STREGEX is wrong, infinite loop below)
;
if KEYWORD_SET(convert_all) then begin
if (STREGEX('1abc','[^0-9a-z]') NE -1) then begin
MESSAGE, 'No working STREGEX, we cannot do this test.'
endif
endif
;
out_list=in_list
;
for iii=0, n_elements(out_list)-1 do begin
;;
out=out_list[iii]
;;
if (out EQ '') then begin
if KEYWORD_SET(convert_all) then out='_'
out_list[iii]=out
break
endif
;;
if KEYWORD_SET(convert_spaces) or KEYWORD_SET(convert_all) then begin
while 1 do begin
res = STRPOS(out, ' ')
if (res EQ -1) then break
STRPUT, out, '_', res
endwhile
endif
;;
if KEYWORD_SET(convert_all) then begin
;;
first_char = STRMID(out, 0, 1)
;;
_ = WHERE(reserved_words EQ STRUPCASE(out), n)
if (n gt 0) then out = '_' + out
while 1 do begin
res = STREGEX(out, '[^0-9A-Za-z_$]')
if res EQ -1 then break
STRPUT, out, '_', res
endwhile
;; numbers and $ are not allowed as first char
;;
if STREGEX(first_char, '^[0-9$]') EQ 0 then out = "_" + out
;; one exception: if first char is "!", is is OK
if (first_char EQ '!') then out='!'+STRMID(out,1)
endif else begin
_ = WHERE(reserved_words EQ STRUPCASE(out), n)
if (STREGEX(out, '^[0-9$]') EQ 0) or $
STREGEX(out, '[^0-9A-Za-z_$]') ne -1 or $
n gt 0 then out=''
endelse
out_list[iii]=out
endfor
;
if KEYWORD_SET(test) then STOP
;
return, out_list
;
end
|