I am porting an application, the existing MakeFile has the following...
ETC_GITATTRIBUTES = $(sysconfdir)/gitattributes
ETC_GITATTRIBUTES_SQ = $(subst ','\'',$(ETC_GITATTRIBUTES))
EXTRA_CPPFLAGS = \
-DETC_GITATTRIBUTES='"$(ETC_GITATTRIBUTES_SQ)"'
So I tried recreating it with...
LOCAL_CFLAGS := -DNO_GETTEXT -DSHA1_HEADER="openssl/sha.h" -DETC_GITATTRIBUTES=/scard/.app
The code both of these are calling is...
system_wide = system_path(ETC_GITATTRIBUTES)
But the second one gives me the following error...
./src/attr.c:476:30: error: expected expression before '/' token
If I hardcode like this...
system_wide = system_path("/sdcard/.app");
This works fine. How do I properly declare my variable in the Android.mk?
Update
I also tried this...
LOCAL_CFLAGS := -DNO_GETTEXT -DSHA1_HEADER="openssl/sha.h" -DETC_GITATTRIBUTES="/scard/.app"
The code after the C-Preprocessor is done looks like this:
system_wide = system_path(/scard/.app)
This is because ETC_GITATTRIBUTES is literally replaced by /scard/.ap. So you'd need to do:
-DETC_GITATTRIBUTES="/scard/.app"
Previous answer was "close" but you needed to escape the quotes apparently...
LOCAL_CFLAGS := -DNO_GETTEXT -DSHA1_HEADER="openssl/sha.h" -DETC_GITATTRIBUTES=\"/scard/.app\"
Related
os.Stat() returns a FileInfo object, which has a Sys() method that returns an Interface{} with no methods.
Though I am able to fmt.Printf() it to "see" the "Gid", I am unable to access "Gid" programmatically.
How do I retrieve the "Gid" of a file here?
file_info, _ := os.Stat(abspath)
file_sys := file_info.Sys()
fmt.Printf("File Sys() is: %+v", file_sys)
Prints:
File Sys() is: &{Dev:31 Ino:5031364 Nlink:1 Mode:33060 Uid:1616 Gid:31 X__pad0:0 Rdev:0 Size:32 Blksize:32768 Blocks:0 Atim:{Sec:1564005258 Nsec:862700000} Mtim:{Sec:1563993023 Nsec:892256000} Ctim:{Sec:1563993023 Nsec:893251000} X__unused:[0 0 0]}
Note: I do not need a portable solution, it just has to work on Linux (notable because Sys() is known to be flaky).
Possibly related: Convert interface{} to map in Golang
The reflect module showed that the data type for Sys()'s return is *syscall.Stat_t, so this seems to work to get the Gid of a file as a string:
file_info, _ := os.Stat(abspath)
file_sys := file_info.Sys()
file_gid := fmt.Sprint(file_sys.(*syscall.Stat_t).Gid)
Please let me know if there is a better way to do this.
I have an unknown identifier on the local like some_values.cursor, I really don't understand why!
qry_update_set_fields (some_keys, some_values, some_unstored_field_names: LINKED_LIST[STRING]): STRING
require
same_some_keys_some_values_count: some_keys.count = some_values.count
local
l_val_c: like some_values.new_cursor
do
Result := ""
l_val_c := some_values.new_cursor
across
some_keys as l_key_c
loop
Result := l_key_c.item + "=" + l_val_c.item + ","
l_val_c.forth
end
if Result.ends_with (",") then
Result.remove_tail (1)
end
ensure
dont_modify_parameters: old some_keys.is_equal (some_keys) and old some_values.is_equal (some_values)
end
working
l_val_c: LINKED_LIST_CURSOR [STRING]
Neither working
l_val_c: LINKED_LIST_CURSOR [like some_values.item]
The example tries using an argument in the qualified anchored type like argument.some_feature. This is not supported. Types, anchored to arguments, are not part of the standard Eiffel and are supported only for backward compatibility in the form like argument.
It's friday and I'm tired and my brain obvs doesn't want to find this answer. Please help.
I want to assign the value to an array. It works in subsequent lines but not in one particular line, even though syntax seems the same to me? It seems to think I'm calling a function??
for entry in PROJECT:
i = i + 1
#A
if entry.startswith("A") :
ProjectA(i) = entry
#B
elif entry.startswith("B"):
ProjectB(i)= entry
#C
elif entry.startswith("C") :
ProjectC(i) = entry
# and Programme
elif entry.startswith("D") :
ProjectD(i) = entry
I'm told the problem is the last line: "ProjectD(i) = entry". Which to me seems like a replica of "ProjectC(i) = entry"
ProjectA(i) looks like you are calling a function; ProjectA[i] looks like an array element.
I'm running a process, which uses a set of parameters defined in a file parameters.py
Now, I'd like to swept the value of one of the parameters over certain range. Thus, I wrote a batch file to automatise the procedure.
Problem
My problem is that I need to modify the 20th line of the file parameter, from value = 200 to value = $VAR, where $VAR sets the new value of the parameter.
Question
Is there a bash command that allows to change a specific target line of the file?
Thank you and cheers.
Try doing this with sed :
sed -i "20s/value = 200/value = $VAR/" file.txt
That will change value = 200 to value = $VAR on line 20. s/// is a skeleton for sed substitutions : s/before/after/
The -i switch edit the file in place
While it's certainly possible, I wouldn't recommend it. One day, someone will add a comment before this line or an empty line and your script will break.
Use sed instead:
sed -e 's/value = 200/value = $VAR/' < parameters.py
An even better solution would be to move everything in parameters.py into parameterdefaults.py like so:
parameterdefaults.py:
options = {
"value": 200,
}
parameters.py:
import parameterdefaults
options = dict( **parameterdefaults.options ) # copy defaults
options['value'] = 10 # Override the few values you need to change
or even better:
codethatneedsparameters.py:
import parameterdefaults
import parameters
options = dict( **parameterdefaults.options ) # copy defaults
options.update( parameters.options ) # merge with changes
Now you can write:
parameters.py:
options = {
"value": 10,
}
The easiest way (but not the best) to do this instead of hacking the script is to change it from
value = 200
to
import os # somewhere at the top if need be.
value = int(os.environ.get('VAR', 200))
That way it can be modified from the calling process what ever that may be.
I'm trying to make a simple Vim script that would create very compact top-level folds for c files. Ideally, if it was run on this code:
static void funca(...)
{
...
}
/* Example comment */
static void funcb(...)
{
...
}
Then it would create folds which would look like this when closed:
+-- x Lines: static void funca(...)----------------------
+-- x Lines: static void funcb(...)----------------------
So basically it would be like foldmethod=syntax with foldlevel=1, except that each fold would start one line further up, and would extend further down to include all following blank lines.
I know how to make one of these folds (assuming foldmethod=manual):
/^{<cr>kVnn?^$<cr>zf
But I'm not sure how to put it into a function. This is my effort:
function Cfold()
set foldmethod=manual " Manual folds
ggzE " Delete all folds
while (/^{<cr>) " Somehow loop through each match
kVnn?^$<cr>zf " This would work fine except for the last function
endwhile
endfunction
map <Leader>f :call Cfold()<cr>
But it isn't valid, I'm not entirely sure how functions work. Also, it won't work for the last function in the file, since it won't find '^{' again. If someone could help me get this working, and somehow add a case for the last function in a file, I would be extremely grateful.
Thanks in advance :)
You can create folds programmatically using the foldexpr and foldtext. Try this, though you may have to tweak CFoldLevel so it doesn't swallow non-function parts of the code:
function! CFoldLevel(lnum)
let line = getline(a:lnum)
if line =~ '^/\*'
return '>1' " A new fold of level 1 starts here.
else
return '1' " This line has a foldlevel of 1.
endif
endfunction
function! CFoldText()
" Look through all of the folded text for the function signature.
let signature = ''
let i = v:foldstart
while signature == '' && i < v:foldend
let line = getline(i)
if line =~ '\w\+(.*)$'
let signature = line
endif
let i = i + 1
endwhile
" Return what the fold should show when folded.
return '+-- ' . (v:foldend - v:foldstart) . ' Lines: ' . signature . ' '
endfunction
function! CFold()
set foldenable
set foldlevel=0
set foldmethod=expr
set foldexpr=CFoldLevel(v:lnum)
set foldtext=CFoldText()
set foldnestmax=1
endfunction
See :help 'foldexpr' for more details.