Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
matti
Mar 31, 2019

do macos and windows have native apis for unicode text segmentation?

id prefer to not use icu on those platforms since they have gently caress all package management and then id have to care about each its cve.
(also icu has some initialization issues when used multithreaded on macos i guess)

Adbot
ADBOT LOVES YOU

matti
Mar 31, 2019

pokeyman posted:

if I understand the relevant terms correctly, I think you want https://developer.apple.com/documentation/foundation/nsstring/1416774-enumeratesubstringsinrange (have a look at the options bitmask). the C equivalent is https://developer.apple.com/documentation/corefoundation/cfstringtokenizer-rf8 if objc is something you want to avoid.

ta least that fixes my techinal problem

matti
Mar 31, 2019

ive been supposing to learn little obj-c anyway so

just need to buy some cheapo screen to hook up my broken screen macbook air to

matti fucked around with this message at 08:51 on Jul 25, 2019

matti
Mar 31, 2019

matti
Mar 31, 2019

pokeyman posted:

oh of course. that makes perfect sense!

matti
Mar 31, 2019

working on my dumb library
code:
int main(void)
{
	freopen("log.txt", "w", stderr);

	if (!crql_open_term(struct frame_info, frame, frame_cb,
	    CRQL_TRUE_COLOR, 0, 0, "Hello, world!", NULL) {
		return crql_print_error();
	}

 	for (;;);
}
 
int frame_cb(struct crql_msg *msg)
{
	struct frame_info *frame = crql_get_frame(msg);

	switch (msg->type) {
	case CRQL_CREATE:
		frame->str = msg->create;
 		return 1;
	case CRQL_DRAW:
		return draw_frame(frame, &msg->draw);
 	case CRQL_KEY:
 		return read_key(frame, &msg->key);
 	case CRQL_QUIT:
		exit(msg->quit);
	}

	return crql_default_cb(msg);
}
im really happy about the ergonomics here for being a win32 style message passing tui api.
if your compiler doesnt support anonymous unions go to hell.
e: coupla fixes
ee: api design when drunk is hard

matti fucked around with this message at 00:54 on Jul 27, 2019

matti
Mar 31, 2019

The freopen function first attempts to close any file that is associated with the specified stream. Failure to close the file is ignored. The error and end-of-file indicators for the stream are cleared.

pff. like you would hope a failure would set the error flag but no actually the exact opposite happens. what a world

matti
Mar 31, 2019

im sure it all works in practice but when writing code examples for documentation id rather not do anything platform specific since you soon get into a chicken and egg situation

matti
Mar 31, 2019

Plorkyeran posted:

reporting failures when closing a file is pretty pointless

nah yeah it makes sense to me now when more sober

just that my mental model of how the FILE error flag worked was just different

file systems are hard

matti
Mar 31, 2019

matti posted:

nah yeah it makes sense to me now when more sober

just that my mental model of how the FILE error flag worked was just different

file systems are hard

though id still prefer itd be set and user explicitly testing ferror() if they want to recover from an open and/or close failure since thatd be more symmetric to how rest of the api works

matti
Mar 31, 2019

whats the thread safe basename() on macos? or is it just that

matti
Mar 31, 2019

probably maybe surely actually going to release my first software

code:
 * This program is made available under the 2-clause BSD license. See
 * LICENSE.txt for details.
 *
 * Copyright 2019 Matti Perakyla
can i just do that? and/or whats a good low down on software copyright law as it pertains to me

im not going the copy+paste the whole license screed into each file that is dog nasty

matti
Mar 31, 2019

Soricidus posted:

that’s probably ok if that’s the license you want!

for a short license like that with a bunch of variations you should really consider putting the license text in every file though to avoid any risk of ambiguity. your ide should have features to manage it for you (so you don’t have to copy-paste or update things by hand in a bunch of places) and to hide that kind of boilerplate by default (so you don’t have to stare at it every time you open a file) at which point it’s basically transparent and not nasty at all.

ah see but i'm a moron and use vi

i'll probably just bite the bullet and use the lawyer vetted option just to make it easier for any potential packagers

matti fucked around with this message at 00:58 on Dec 20, 2019

matti
Mar 31, 2019

but then i'd have to deal with vimscript and i would rather avoid that

eh i'll switch to emacs if it becomes an issue

matti
Mar 31, 2019

i just assume any vim plugin will eventually break on some weird edge case and i'm stuck with debugging it

...i will try it, thank you

matti
Mar 31, 2019

i mean meth exists when push comes to shove, i'll do fine

matti
Mar 31, 2019

regex is the worst PL

matti
Mar 31, 2019

Powerful Two-Hander posted:

the moral of the story is: whatever you do it's gonna suck in some way and you'll wish you did something else, but you have to deal with that and not get super paranoid about what ifs

or get seriously stoned/drunk and convince yourself there's a multi verse and there's an alternate you out there that did this stuff and is successful, handsome and who makes good posts

i spent my 20s drinking beer and listening to punk rock op

now im soon 30 and might as well get some poo poo job writing java so i can finance doing the very same

but it definitely doesn't suck

matti
Mar 31, 2019

then again i'm from massive privilege

matti
Mar 31, 2019

https://paste.ofcode.org/DtfrvVMDpDNh7GvXYj9srK

can i get some c&s on my commenting? i was completely hopeless just a year ago but im starting to feel pretty comfortable now

still don't know how to comma so i just wing it

matti
Mar 31, 2019

Phobeste posted:

not really. you can't allow random byte access. you can allow random code point access. this gets insanely squirrelly around combining marks though. a good example are the family emojis, which are supposed to be composed from individual emojis. paste a family emoji into a python shell and you might get a string length of 7, which is presumably 7 codepoints - four person emojis and 3 zero width joiners between them. access element 1 of this string and you will get '\u200d', unicode codepoint u+200d, ZERO WIDTH JOINER. this is encoded in utf-8 as 3 bytes (according to me loving around). seven codepoints, one glyph (in most rendering engines - sometimes you get rendering engine weirdness where that ends up being a string of four people, if something stripped unprintable characters in between).

it's all awful i guess is my point

does unicode have a recursion depth limit for parsing that?

but yes, if you're doing anything bordering semantics with unicode forget about it and link with ICU

unicode should be thought of as a black box

matti fucked around with this message at 18:22 on Jan 14, 2020

matti
Mar 31, 2019

The_Franz posted:

also wchar_t is an unholy abomination and should be burned at the stake, the ashes scattered to the most remote corners of the earth and forgotten for all eternity

ucs-2 was a beautifully naive dream and i appreciate it for that

matti
Mar 31, 2019

Phobeste posted:

i think the commenting here is good. calls out the things that would be surprising to someone who knows the language but is just starting to look at this specific use case. theres uh some other stuff i disagree with but the comments seem good

"you really should stop fitting a c++ shaped peg into a c shaped hole"

edit: its xmacros, once you start relying on xmacros its best to move on

matti fucked around with this message at 20:25 on Jan 14, 2020

matti
Mar 31, 2019

Plorkyeran posted:

posix says that filenames are just arbitrary strings of bytes as a garbage way of "supporting" systems that predate utf-8 and also don't store what encoding the filenames are encoded with anywhere. for some reason this makes linux users think that they actually should create files with names that are just arbitrary bytes and not utf-8.

https://dwheeler.com/essays/fixing-unix-linux-filenames.html

its a mess

edit disclaimer i dont agree or disagree with any of that time cube rear end website's opinions

matti
Mar 31, 2019

so if i were to write a c++ linux software how hosed would i be if i used visual studio? definitely not going to bang none of that in a terminal

matti
Mar 31, 2019

CRIP EATIN BREAD posted:

do you mean visual studio or visual studio code? because i dont know how visual studio could possibly work.

if you really want a decent c++ ide on linux just pay the $89 or whatever it is for CLion https://www.jetbrains.com/clion/

https://devblogs.microsoft.com/cppblog/linux-development-with-c-in-visual-studio/

its a thing

matti
Mar 31, 2019

yeah clion in actual non WSL linux is the alternative, i've heard its quite good

matti
Mar 31, 2019

The_Franz posted:

clion is good. better than msvc now imo (particularly when it comes to refactoring tools, there is absolutely no comparison) and getting better with every release, as opposed to visual studio which seems to be getting worse every year

don't write software in msvc if you want someone to be able to build it with clang/gcc or you will spend hours fixing warnings and errors because microsoft's compiler still lets you get away with things that clang and gcc don't

i assume this is c++ specific advise since in c _GNUC_ is far more permissive and flexible

matti
Mar 31, 2019

cl.exe c99 has been fine for good couple years now at least

matti
Mar 31, 2019

no don't worry i asked i'm taking the advise

matti
Mar 31, 2019

man 2 sysctl posted:

Glibc does not provide a wrapper for this system call; call it using
syscall(2). Or rather... don't call it: use of this system call has
long been discouraged, and it is so unloved that it is likely to
disappear in a future kernel version. Since Linux 2.6.24, uses of
this system call result in warnings in the kernel log. Remove it
from your programs now; use the /proc/sys interface instead.

am i really supposed to parse a loving text file? like i grieve enough about every program having to be parser but this is something else, there has to be a wrapper right?

right i'm probably putting too much faith in some FSF jack-offs's opinionated manpage

matti
Mar 31, 2019

and i wouldn't have to care about none of this if mmap() didn't set the same errno for two different error conditions

e: i must be doing something wrong since this is so difficult. whats the best way to distinguish between

ENOMEM No memory is available.

and

ENOMEM The process's maximum number of mappings would have been
exceeded. This error can also occur for munmap(), when
unmapping a region in the middle of an existing mapping, since
this results in two smaller mappings on either side of the
region being unmapped.

obviously i can't expect any solution to be atomic but being correct 99% of time is good enough for my purposes

matti fucked around with this message at 21:09 on Jan 23, 2020

matti
Mar 31, 2019

CRIP EATIN BREAD posted:

These are essentially the same thing. Why would you need to differentiate it?

it's for unit testing that file IO functions work properly with large values. basically i'm mirroring some multiple of a pagesize file over a big range of memory.

one error is that there's just not enough virtual memory available, in which case the test is void. another case is that the function is misconfigured and the pages its mapping are too small, in which case the test itself is broken.


i'll probably just disable those tests on 32 bit builds and treat every 64 bit ENOMEM as fatal (e: since 2^32-1 is the upper limit of any input value and i don't need to read variables wider than 4 bytes)

matti fucked around with this message at 23:54 on Jan 23, 2020

matti
Mar 31, 2019

its likely that ive missed something in the documentation and have a wrong idea how the internal mmap() structures work

matti
Mar 31, 2019

i would do make a windows desktop software w/ c++

c apis right? mcv is jank, atl is somehow an alternative despite being an template library. com is an abi but the terminology is little messed. winrt is a stillbirth??

matti
Mar 31, 2019

think i have too much trauma from using terrible python qt software and the ide being sligthly broken on a clean install

i can try

matti
Mar 31, 2019

i wrote an xml schema and it was surprisingly ok

the docs are incredibly opaque though

matti
Mar 31, 2019

Shaggar posted:

Idk if I've ever hand written xsd but it's real good in terms of usages.

its good that i have sensible error messages now instead of python "error handling" (there is none)

matti
Mar 31, 2019

i know gently caress all about maffs, is 32 bit xorshift good enough for a video game or

Adbot
ADBOT LOVES YOU

matti
Mar 31, 2019

pro motion ng is a "good" software thats terrible to launch from the start menu, poo poo takes good 3 seconds to register

which is indistinguishable from normal star menu lag and each enter press launches a new process. i usually end up with at least 2 instances of it

i'm not sure how the developer managed that

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply