So kind of struggling with French lessons from 30 years ago for your LISP... but you have been good to ask the question in English, I'll have a go at an answer.
Unless I am wrong your first point and last point of the lines are
point_debut_lineaire
point_fin_lineaire
if the line is drawn in reverse, can you swap these over so that point_debut_lineaire becomes point_fin_lineaire.. and in which case all you need to do is an if routine for the smallest x coordinate to be point_debut_linear ? (about line 385)
Something like
(if (< (nth 0 point_fin_lineaire) (nth 0 point_debut_lineaire) )
(progn
(setq temp point_fin_lineaire)
(setq point_fin_lineaire point_debut_lineaire)
(setq point_debut_lineaire temp)
) ;end progn
) ;end if
obviously I might be wrong.