Comments (6)
I'll revise it shortly.
from supdup.
Updated to just use the portable version everywhere.
Seems that Travis doesn't have libbsd
, so it's likely others won't either.
from supdup.
I don't follow. There is no benefit here to use strlcpy? No error checking is done on the return value. You also changed strncpy calls to strlcpy calls?
from supdup.
Certainly doing buffer overflow checks throughout would be a welcome improvement.
from supdup.
Yes, in this particular case there isn't any real change.
However, this does reduce the overall complexity of the code by not requiring operating system specific #ifdef's or using external libraries and eases future maintenance by having a single platform agnostic way to do things.
Also, the replacement of strncpy
was:
#ifdef __OpenBSD__
strlcpy(myloc, argv[1], sizeof(myloc));
#else
strncpy(myloc, argv[1], sizeof(myloc));
#endif
Using strlcpy
on BSD and strncpy
and friends on other platforms adds, at a bare minimum, three lines (conditional compilation, no less) for each and every instance of use (not including the duplicated statement itself), while the portable strlcpy
implementation is just seven statements in total (not counting variable declarations, comments, and formatting). It has been stable for nearly 25 years and is unlikely to change in the future. Not to mention, with strncpy
, there is the need to manually handle NULL-termination in cases of truncation, etc.
Having a single function to use on all platforms that uses the same code, works exactly the same everywhere, and also reduces the total lines of code needed while removing the need for conditional compilation is really the benefit.
(IMO, to this end, the __OpenBSD__
#ifdef's should be removed all together if the change is accepted - I did not do so in this commit to keep the patch to the minimum viable change.)
from supdup.
Then I think I'd lke to see the change addresses the entirety of the problem, as it is now I see little benefit. You say that it reduces a few #if's -- but the added code for strlcpy(3) has a size and maintenance cost as well, over 25 years much can happen... :-)
from supdup.
Related Issues (16)
- Not building on OS X 10.12 with clang HOT 3
- Use SAIL charset without translation to Unicode HOT 2
- TOPS-10 SUPDUP HOT 2
- Connect through Chaosnet HOT 12
- Graphics extension HOT 17
- Unicode?
- Ƶ
- Gotta merge them all! HOT 12
- Extended ASCII character 32 should be ≠ HOT 1
- Compilation failure on OpenBSD HOT 5
- supdupd: The result of a left shift is undefined when the left operand is negative. HOT 2
- Output SAIL charset as Unicode HOT 19
- Problems using terminfo HOT 1
- Runtime changes of terminal size HOT 10
- Knight TV font HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from supdup.