Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
881 B

  1. ;# Usage:
  2. ;# %foo = ();
  3. ;# &abbrev(*foo,LIST);
  4. ;# ...
  5. ;# $long = $foo{$short};
  6. #
  7. # This library is no longer being maintained, and is included for backward
  8. # compatibility with Perl 4 programs which may require it.
  9. #
  10. # In particular, this should not be used as an example of modern Perl
  11. # programming techniques.
  12. #
  13. # Suggested alternative: Text::Abbrev
  14. #
  15. package abbrev;
  16. sub main'abbrev {
  17. local(*domain) = @_;
  18. shift(@_);
  19. @cmp = @_;
  20. local($[) = 0;
  21. foreach $name (@_) {
  22. @extra = split(//,$name);
  23. $abbrev = shift(@extra);
  24. $len = 1;
  25. foreach $cmp (@cmp) {
  26. next if $cmp eq $name;
  27. while (@extra && substr($cmp,0,$len) eq $abbrev) {
  28. $abbrev .= shift(@extra);
  29. ++$len;
  30. }
  31. }
  32. $domain{$abbrev} = $name;
  33. while ($#extra >= 0) {
  34. $abbrev .= shift(@extra);
  35. $domain{$abbrev} = $name;
  36. }
  37. }
  38. }
  39. 1;