X11 is making me lose my sanity

X11 is making me lose my sanity

Postby Cyborg Girl » Sun Jan 12, 2014 9:23 am

As a programming exercise, I decided to resurrect and modernize a dead X11 window manager (and maybe bloat it up with features at some point).

Step 1: make it actually compile. (Done.)

Step 2: turn on -Werror and fix all the warnings. (Still working on that...)

Step 3: start adding the features I want. Make sure it compiles without errors or warnings. Make sure it actually runs, and does what I want. Rinse and repeat...

Unfortunately that second part is is a bit like wrestling with a boa constrictor, if you know what I mean.

Case in point, the very first one:

Code: Select all
  char **missing, *def = "-";
  int nmissing;

  // load the fontset                                                           
  fs = XCreateFontSet(_display.XDisplay(), fontsetname.c_str(),
                      &missing, &nmissing, &def);


That first line generates a warning in C++. def is initialized from a constant string literal, but is itself mutable, which may not be what you expect; and it gets modified by XCreateFontSet(), whose documentation doesn't actually specify the length of the string it will stuff into that buffer. def is probably going to be initialized to 2 bytes ('-' and the null terminator). XCreateFontSet might then try to force, I dunno, 16 bytes into it. Oops. Not sure how I'll deal with that.

(Also this is the first time I've seen a pointer to a pointer to a pointer... Anywhere, I think. Not sure if that's just because I'm a newbie.)

Anyway I guess I'll sleep on it.
User avatar
Cyborg Girl
Boy Genius
 
Posts: 2138
Joined: Mon May 27, 2013 2:54 am

Re: X11 is making me lose my sanity

Postby Rommie » Sun Jan 12, 2014 7:02 pm

My favorite thing about the new update (as in, that sarcastic least favorite sort of way) is they got rid of underlines and made them spaces, so this_file.py now shows up as this file.py.

No idea why the crap you would do that!
Yes, I have a life. It's quite different from yours.
User avatar
Rommie
 
Posts: 3993
Joined: Mon May 27, 2013 10:04 am

Re: X11 is making me lose my sanity

Postby Cyborg Girl » Sun Jan 12, 2014 7:36 pm

Wha... What software? Spaces in filenames can be a hazard on almost every platform.
User avatar
Cyborg Girl
Boy Genius
 
Posts: 2138
Joined: Mon May 27, 2013 2:54 am

Re: X11 is making me lose my sanity

Postby Sigma_Orionis » Sun Jan 12, 2014 7:52 pm

Yeah, what update, on WHAT software?
Sic Transit Gloria Mundi
User avatar
Sigma_Orionis
Resident Oppressed Latino
 
Posts: 4491
Joined: Mon May 27, 2013 2:19 am
Location: The "Glorious Socialist" Land of Chavez

Re: X11 is making me lose my sanity

Postby Cyborg Girl » Sun Jan 12, 2014 8:14 pm

Okay, re the OP, XCreateFontSet apparently makes a copy of the buffer... That's why it's passed as a pointer to a pointer, not just a pointer. Or something. I'm confused.

Edit: okay, it makes a copy of the buffer, and doesn't change the original at all. So why the hell does it specifically require a mutable buffer, when it never actually puts anything in it? *tears hair out*
User avatar
Cyborg Girl
Boy Genius
 
Posts: 2138
Joined: Mon May 27, 2013 2:54 am

Re: X11 is making me lose my sanity

Postby Cyborg Girl » Sun Jan 12, 2014 8:32 pm

Yeah okay this is just libX11 being total shit. RAARGH.
User avatar
Cyborg Girl
Boy Genius
 
Posts: 2138
Joined: Mon May 27, 2013 2:54 am

Re: X11 is making me lose my sanity

Postby Cyborg Girl » Sun Jan 12, 2014 10:30 pm

Apparently the deal is that const declarations were only added to C in 1999, and X for the most part has not started making use of them in the past ~15 years. :(
User avatar
Cyborg Girl
Boy Genius
 
Posts: 2138
Joined: Mon May 27, 2013 2:54 am

Re: X11 is making me lose my sanity

Postby Sigma_Orionis » Sun Jan 12, 2014 11:47 pm

I never needed to see the code of X11 to determine it was crap...........
Sic Transit Gloria Mundi
User avatar
Sigma_Orionis
Resident Oppressed Latino
 
Posts: 4491
Joined: Mon May 27, 2013 2:19 am
Location: The "Glorious Socialist" Land of Chavez

Re: X11 is making me lose my sanity

Postby Cyborg Girl » Mon Jan 13, 2014 12:00 am

Update: the program now compiles with -Werror -Wall, and runs without any issues.

Boo ya.

Now to actually do something useful with it. :?
User avatar
Cyborg Girl
Boy Genius
 
Posts: 2138
Joined: Mon May 27, 2013 2:54 am


Return to Sci-Tech… and Stuff

Who is online

Users browsing this forum: No registered users and 31 guests

cron