IRC Logs for #crux-devel Tuesday, 2019-02-19

*** xor29ah has quit IRC01:15
*** xor29ah has joined #crux-devel01:17
*** xor29ah has quit IRC11:44
*** xor29ah has joined #crux-devel11:49
*** Abdullah has joined #crux-devel13:13
*** onodera has joined #crux-devel18:32
jaegerryuo: I'll move the question here instead of cluttering up #crux20:20
jaegerI'm poking at the 'pkginfo -o <whatever>'20:20
jaeger thing again20:20
jaegerIf you run 'pkginfo -o /bin/bash' for example, you get 'bash     bin/bash'20:21
jaegerIn the package database, all files are missing leading slashes20:21
jaegerin the c++ version it just adds "/" to the string: const string file('/' + *j);20:21
jaegernot as easy to do in c20:21
jaegerSo I'm just thinking about the least dumb way to do it :D20:22
ryuowouldn't it be simplest to just prepend it during output of the data?20:22
ryuoprintf("%s /%s\n", ...)20:22
ryuoor so20:22
jaegerIt doesn't show up in the output and I don't want mine to be different from the original20:22
jaegerIt happens during the regex check20:23
jaegerso if you pass in '/bin/bash' as your regex, every file in the package db is checked with "/" prepended20:23
ryuoi see.20:23
ryuowell, one option...20:24
jaegerMaybe it's simplest just to make an extra string with / and the original contents, then free it right after20:24
ryuois to copy it to a temporary stack buffer before running the compiled regex.20:24
jaeger(a copy of the original data)20:24
ryuodon't bother with malloc for this, man. it's a waste of precious CPU time.20:24
ryuopaths are capped at PATH_MAX for all practical purposes.20:25
ryuojust format it with snprintf and then run the regex against the buffer.20:25
ryuoyou'll save on the overhead of malloc at least.20:25
jaegerdidn't think of snprintf, that's a good call20:25
jaegerThanks for the input20:25
ryuojaeger: for future reference, treasure snprintf. it's a giant helper.20:26
ryuoasprintf if you must have it mallocd.20:26
jaegeryeah, I can see how it would be20:26
ryuoi prefer stack buffers as much as possible.20:26
ryuoespecially when i don't need to keep the copy.20:27
jaegerSo you'd just create some char blah[MAX_PATH] and snprintf into that?20:27
jaegersimple enough20:27
jaegerer, yeah20:27
ryuolonger paths are invalid anyway so20:27
ryuotruncation won't cause any real issues.20:27
jaegerIn the end there are probably quite a few optimizations that could be made to my code, but it's all pretty simple stuff that works on small amounts of data and it's already faster than the c++ version20:28
ryuojaeger: fyi, i always use snprintf for safe string formatting.20:28
ryuoit has overhead, but it's portable solution to the problem.20:28
ryuostrlcpy/strlcat aren't even in POSIX.20:28
ryuoplus it's far more powerful.20:29
ryuoprintf is rather powerful beastie.20:29
ryuoi usually ended up wrapping snprintf in my own functions.20:29
ryuoit's possible to make a form of snprintf that appends instead of overwrites.20:29
ryuoit's very simple even.20:29
ryuosnprintf(buf+strlen(buf), sizeof(buf)-strlen(buf), ...)20:30
ryuoafaik the math on that is solid.20:30
ryuoi've used it for years.20:30
ryuoi tested it fully. it should be error free.20:30
*** onodera has quit IRC22:31
jaegerI wonder if it's safe to assume that inside an archive, a hardlinked file will come after the file it duplicates22:48

Generated by 2.14.0 by Marius Gedminas - find it at!