lstpatch.sty 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. %%
  2. %% 1998/11/23: First patch for listings.sty
  3. %%
  4. %% (c) 1998 Carsten Heinz
  5. %%
  6. \def\lstlanguage@[#1]#2{%
  7. \lst@LocateLanguage[#1]{#2}%
  8. \@ifundefined{\lst@requested}%
  9. {{\catcode`\^^M=9\catcode`\"=12\makeatletter %
  10. \input{\[email protected]}}}{}%
  11. \@ifundefined{\lst@requested}%
  12. {\PackageError{Listings}%
  13. {\ifx\@empty\lst@dialect@\else \lst@dialect@\space of \fi %
  14. \lst@language@\space undefined}{The driver file is not
  15. loadable or doesn't support the language.^^J%
  16. Type <RETURN> to proceed without changing the language.}}%
  17. {\lsthk@SetLanguage %
  18. \csname\lst@requested\endcsname %
  19. %% modification of
  20. % \def\lst@language{#1}\lst@Normalize\lst@language %
  21. % \def\lst@dialect{#2}\lst@Normalize\lst@dialect}}
  22. \def\lst@language{#2}\lst@Normalize\lst@language %
  23. \def\lst@dialect{#1}\lst@Normalize\lst@dialect}}
  24. %% end modification
  25. %
  26. %% load .fd files
  27. \lst@AddToHook{BeforeSelectCharTable}
  28. {\setbox\@tempboxa\hbox{\lst@labelstyle \lst@loadfd}}
  29. %% end load .fd files
  30. %
  31. %% move \let\lst@lastother\relax to end of macros
  32. \def\lst@Output{%
  33. \ifnum\lst@length=\z@\else %
  34. \lst@NewLine \lst@UseLostSpace %
  35. \hbox to \lst@length\lst@width{%
  36. \lst@lefthss %
  37. \lsthk@Output \lst@thestyle{%
  38. \expandafter\lst@FillOutputBox\the\lst@token\relax}%
  39. \lst@righthss}%
  40. \global\advance\lst@pos -\lst@length %
  41. \lst@token{}\lst@length\z@ %
  42. \fi %
  43. \let\lst@lastother\relax}
  44. \def\lst@OutputFlexible{%
  45. \ifnum\lst@length=\z@\else %
  46. \lst@NewLine \lst@UseLostSpace %
  47. \setbox\@tempboxa\hbox{%
  48. \lsthk@Output \lst@thestyle{\the\lst@token}}%
  49. \lst@CalcLostSpaceAndOutput %
  50. \fi %
  51. \let\lst@lastother\relax}
  52. %% end move \let\lst@lastother\relax to end of macros
  53. %
  54. %% correct bug of \lst@Aspect{texcs}{\def\lst@texcs{#1}}
  55. \let\lstS@Aspect\lst@Aspect
  56. \def\lst@Aspect#1{\def\@tempa{#1}\def\@tempb{texcs}%
  57. \ifx\@tempa\@tempb %
  58. \expandafter\lst@AspectTeX %
  59. \fi %
  60. \lstS@Aspect{#1}}
  61. \def\lst@AspectTeX#1#2#3{%
  62. \@ifundefined{KV@lst@#2}%
  63. {\let\lst@ifnew\iftrue}{\let\lst@ifnew\iffalse}%
  64. \lst@ifnew %
  65. \else %
  66. \expandafter\@gobblefour %
  67. \fi %
  68. \lstdefine@key{lst}{#2}{\edef\lst@texcs{##1}}}
  69. %% end correct bug of \lst@Aspect{texcs}{\def\lst@texcs{#1}}